0

I've downloaded and compiled zlib, and I am statically linking zlibwapi.lib to my C++ project on Visual Studio 2015. However, if I don't use the dll and launch my program, it complains about it:

"The program can't start because zlibwapi.dll is missing from your computer."

With the DLL though, no error message shows up and the program works fine.
Is there any way I could use my program without the need of zlibwapi.dll?

Spook
  • 301
  • 4
  • 9
  • When I've had this type of problem in MinGW / CMake, I add `-static` to the `CMAKE_CXX_FLAGS` and it shuts up. – user2475059 Apr 13 '16 at 17:07
  • Oh, I completely forgot to add that I'm using Visual Studio 2015 to compile it, I will add it to the question. I guess your solution wouldn't work for me, correct me if I'm wrong. – Spook Apr 13 '16 at 17:09
  • Would [this](http://stackoverflow.com/questions/8581247/vs2010-link-in-a-single-library-statically) help? – user2475059 Apr 13 '16 at 17:11
  • I think it did! It seems you may also need a DLL at runtime and it's completely normal. The part that confuses me though, is that another application doesn't use the DLL yet it is statically linking zlib. – Spook Apr 13 '16 at 17:16
  • [Here's](http://stackoverflow.com/questions/33402337/static-zlib-1-2-8-linking-on-visual-studio-2012) a different one that may be a bit more to your point. – user2475059 Apr 13 '16 at 17:20
  • I did try that actually, but it's giving me errors with the CreateFile2 API. For some reason, even if I tell it NOT to target W8, it still will. – Spook Apr 13 '16 at 18:55

1 Answers1

0

I've done this with MSVC 10. I created a separate project for zlib and built it as a static library (.lib), which I then added to my main application project. The projects are not in the same workspace. I did have to build a separate copy of zlib.lib for 32-bit and 64-bit builds of my app, and the app itself uses MFC in a dynamic DLL. Everything links just fine, and zlib is not in a DLL.

Logicrat
  • 4,438
  • 16
  • 22