Why does my statically complied executable need zlib1.dll? Topic is solved

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
katuday
Earned some good credits
Earned some good credits
Posts: 134
Joined: Fri Aug 17, 2012 2:22 am

Why does my statically complied executable need zlib1.dll?

Post by katuday »

My environment:
Windows 7
Visual Studio 2017 ( 15.2 )

I built my wxWidgets libraries with the following command:

Code: Select all

nmake -f makefile.vc TARGET_CPU=X64 BUILD=release  MONOLITHIC=0 SHARED=0 RUNTIME_LIBS=dynamic
When I launch my program I get The program can't start because zlib1.dll is missing.....

The same program built using Visual Studio 2013 does not exhibit the same behaviour. It runs without asking for zlib1.dll because I assume the library is statically linked.
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Why does my statically complied executable need zlib1.dll?

Post by doublemax »

Do you see the same when trying one of the wxWidgets samples? (Try the "image" sample, as it can load PNGs, it must use the zlib library)
Use the source, Luke!
katuday
Earned some good credits
Earned some good credits
Posts: 134
Joined: Fri Aug 17, 2012 2:22 am

Re: Why does my statically complied executable need zlib1.dll?

Post by katuday »

doublemax wrote:Do you see the same when trying one of the wxWidgets samples? (Try the "image" sample, as it can load PNGs, it must use the zlib library)
The sample "image" does not exhibit the same behaviour. Now I am not sure where else to look. I am using the exact same compile link command

Code: Select all

nmake -f makefile.vc TARGET_CPU=X64 BUILD=release SHARED=0 RUNTIME_LIBS=dynamic
katuday
Earned some good credits
Earned some good credits
Posts: 134
Joined: Fri Aug 17, 2012 2:22 am

Re: Why does my statically complied executable need zlib1.dll?

Post by katuday »

Adding wxzlibd.lib to the Linker / input property solved my problem.
No other wx libraries is explicitly added so I am nit sure why zlib has to be treated differently.
Also this was never an issue with Visual Studio 2013.
Conclusion: my problem is solved but I still don't have a good explanation.
katuday
Earned some good credits
Earned some good credits
Posts: 134
Joined: Fri Aug 17, 2012 2:22 am

Re: Why does my statically complied executable need zlib1.dll?

Post by katuday »

katuday wrote:Adding wxzlibd.lib to the Linker / input property solved my problem.
No other wx libraries is explicitly added so I am nit sure why zlib has to be treated differently.
Also this was never an issue with Visual Studio 2013.
Conclusion: my problem is solved but I still don't have a good explanation.
Found the real reason.
I had installed vcpkg ( https://github.com/Microsoft/vcpkg ) for zlib and enabled user-wide integration.
It is the zlib version that was being used.
vcpkg onlly support VS 2015 and 2017 that's why I never had issues with VS 2013.
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Why does my statically complied executable need zlib1.dll?

Post by doublemax »

Good to know. Thanks for the update.
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Why does my statically complied executable need zlib1.dll?

Post by ONEEYEMAN »

Hi,
Keep in mind that you might have a different set of issues due to incompatibility - you compiled wxWidgets in release mode but using zlibd library, which is compiled in debug mode.

You need to either recompile wxWidgets or find a release version of zlib library.

Thank you.
katuday
Earned some good credits
Earned some good credits
Posts: 134
Joined: Fri Aug 17, 2012 2:22 am

Re: Why does my statically complied executable need zlib1.dll?

Post by katuday »

ONEEYEMAN wrote:Hi,
Keep in mind that you might have a different set of issues due to incompatibility - you compiled wxWidgets in release mode but using zlibd library, which is compiled in debug mode.

You need to either recompile wxWidgets or find a release version of zlib library.

Thank you.
Thanks for the remainder.
In the end I un-installed the vcpkg version of zlib and don't need to add the library name explicitly; now all is good now.
Post Reply