Fixed static linking on Windows.

This commit is contained in:
Pietro Gagliardi 2016-05-29 18:35:06 -04:00
parent 56cb25b230
commit be8a957689
10 changed files with 107 additions and 7 deletions

View File

@ -23,7 +23,8 @@ This README is being written.<br>
*Note that today's entry may be updated later today.*
* **29 May 2016**
* Thanks to @pcwalton, we can now statically link libui! Simply do `make STATIC=1` instead of just `make`. Right now it only works on GTK+ and OS X.
* Thanks to @pcwalton, we can now statically link libui! Simply do `make STATIC=1` instead of just `make`.
* On Windows you must provide a Common Controls 6 manifest for output static libraries to work properly.
* **28 May 2016**
* As promised, **the minimum system requirements are now OS X 10.8 and GTK+ 3.10 for OS X and Unix, respectively**.

View File

@ -59,16 +59,26 @@ endif
OFILES = \
$(subst /,_,$(CFILES)) \
$(subst /,_,$(CXXFILES)) \
$(subst /,_,$(MFILES)) \
$(subst /,_,$(MFILES))
ifeq (,$(STATIC))
OFILES += \
$(subst /,_,$(RCFILES))
else
RESFILES = \
$(subst /,_,$(RCFILES))
endif
OFILES := $(OFILES:%=$(OBJDIR)/%.o)
OUT = $(OUTDIR)/$(NAME)$(SUFFIX)
ifneq (,$(STATIC))
RESOUT = $(OUTDIR)/$(NAME).res
endif
# otherwise keep $(RESOUT) empty
# TODO use $(CC), $(CXX), $(LD), and s$(RC)
$(OUT): $(OFILES) | $(OUTDIR)
$(OUT): $(OFILES) $(RESOUT) | $(OUTDIR)
ifeq (,$(STATICLIB))
@link -out:$(OUT) $(OFILES) $(LDFLAGS)
else
@ -99,6 +109,9 @@ endif
$(OBJDIR)/%.rc.o: $$(subst _,/,%).rc $(HFILES) | $(OBJDIR)
@rc -nologo -v -fo $@ $(RCFLAGS) $<
@echo ====== Compiled $<
$(RESOUT): $$(RCFILES) $(HFILES) | $(OUTDIR)
@rc -nologo -v -fo $@ $(RCFLAGS) $<
@echo ====== Compiled $<
$(OBJDIR) $(OUTDIR):
@mkdir $@

View File

@ -23,6 +23,9 @@ HFILES += \
ifeq ($(OS),windows)
RCFILES += \
examples/resources.rc
ifneq (,$(STATIC))
RCFLAGS += -D _UI_STATIC
endif
endif
NAME = $(EXAMPLE)
@ -49,7 +52,7 @@ else
# TODO is there an equivalent to -L?
LDFLAGS += $(OUTDIR)/libui.lib
else
LDFLAGS += $(OUTDIR)/libui.lib $(NATIVE_UI_LDFLAGS)
LDFLAGS += $(OUTDIR)/libui.lib $(OUTDIR)/libui.res $(OUTDIR)/$(NAME).res $(NATIVE_UI_LDFLAGS)
endif
endif

View File

@ -13,6 +13,12 @@ HFILES += \
NAME = test
SUFFIX = $(EXESUFFIX)
ifeq ($(OS),windows)
ifneq (,$(STATIC))
RCFLAGS += -D _UI_STATIC
endif
endif
ifeq ($(TOOLCHAIN),gcc)
ifeq (,$(STATIC))
LDFLAGS += -L$(OUTDIR) -lui
@ -29,8 +35,12 @@ ifeq ($(TOOLCHAIN),gcc)
LDFLAGS += -Wl,-rpath,'$$ORIGIN'
endif
else
ifeq (,$(STATIC))
# TODO is there an equivalent to -L?
LDFLAGS += $(OUTDIR)/libui.lib
else
LDFLAGS += $(OUTDIR)/libui.lib $(OUTDIR)/libui.res $(OUTDIR)/$(NAME).res $(NATIVE_UI_LDFLAGS)
endif
endif
# executables are not shared libraries

View File

@ -34,7 +34,7 @@ static CGFloat stepperYDelta(void)
{
// 10.8 - 0
// 10.9 - 0
// 10.10 - xxx
// 10.10 - -1
// 10.11 - -1
return -1;
}

1
doc/static Normal file
View File

@ -0,0 +1 @@
comctl6

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="*"
name="CompanyName.ProductName.YourApplication"
type="win32"
/>
<description>Your application description here.</description>
<!-- we DO need comctl6 in the static case -->
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--The ID below indicates application support for Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!--The ID below indicates application support for Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
</application>
</compatibility>
</assembly>

View File

@ -6,4 +6,8 @@
// this is the Common Controls 6 manifest
// TODO set up the string values here
// 1 is the value of CREATEPROCESS_MANIFEST_RESOURCE_ID and 24 is the value of RT_MANIFEST; we use it directly to avoid needing to share winapi.h with the tests and examples
#ifndef _UI_STATIC
1 24 "example.manifest"
#else
1 24 "example.static.manifest"
#endif

View File

@ -6,4 +6,8 @@
// this is the Common Controls 6 manifest
// TODO set up the string values here
// 1 is the value of CREATEPROCESS_MANIFEST_RESOURCE_ID and 24 is the value of RT_MANIFEST; we use it directly to avoid needing to share winapi.h with the tests and examples
#ifndef _UI_STATIC
1 24 "test.manifest"
#else
1 24 "test.static.manifest"
#endif

32
test/test.static.manifest Normal file
View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="*"
name="CompanyName.ProductName.YourApplication"
type="win32"
/>
<description>Your application description here.</description>
<!-- we DO need comctl6 in the static case -->
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--The ID below indicates application support for Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!--The ID below indicates application support for Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
</application>
</compatibility>
</assembly>