Skip to content

Commit

Permalink
Fix static linking.
Browse files Browse the repository at this point in the history
Make static linking possible when using Visual Studio and when using GNU
Make. To link statically with GNU Make, do:

make LDFLAGS=-static ...other arguments...

To link statically with VS 2015, install static versions of
dependencies:

vcpkg install libpng:x86-windows-static gflags:x86-windows-static

change the runtime library setting in the project from /MD to /MT,
attempt to build with VS and then run:

c:\path\to\msbuild /p:Configuration=Release /p:VcpkgTriplet=x86-windows-static /p:VcpkgEnabled=true
  • Loading branch information
robryk committed Dec 21, 2016
1 parent 0e49009 commit f86b901
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions guetzli.make
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ifeq ($(config),release)
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS +=
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) -s -lpng -lgflags_nothreads
ALL_LDFLAGS += $(LDFLAGS) -s -lpng -lgflags_nothreads -lz
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
Expand All @@ -51,7 +51,7 @@ ifeq ($(config),debug)
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS +=
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) -lpng -lgflags_nothreads
ALL_LDFLAGS += $(LDFLAGS) -lpng -lgflags_nothreads -lz
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
Expand Down
2 changes: 2 additions & 0 deletions guetzli.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<GenerateDebugInformation>false</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
</Link>
</ItemDefinitionGroup>
Expand All @@ -85,6 +86,7 @@
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
</Link>
</ItemDefinitionGroup>
Expand Down
4 changes: 3 additions & 1 deletion premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ workspace "guetzli"
language "C++"
includedirs { ".", "third_party/butteraugli" }
filter "action:gmake"
linkoptions { "-lpng", "-lgflags_nothreads" }
linkoptions { "-lpng", "-lgflags_nothreads", "-lz" }
filter "action:vs*"
links { "shlwapi" }
filter {}
-- This should work with gflags 2.x. The gflags namespace is absent in
-- gflags-2.0, which is the version in Ubuntu Trusty package repository.
Expand Down

0 comments on commit f86b901

Please sign in to comment.