tags:

views:

156

answers:

2

My executable needs zlib1.dll to run,

and I need to keep them together now and then.

How can I merge it into the executable to save the trouble?

I'm using cmake to build the executable.

UPDATE

zlib1.dll is not directly included by my programe,but required by libpng14-14.dll(one dll of the gtk bundle)

+1  A: 

It sounds like you want to link statically so that your program does not require the presence of zlib1.dll in order to run. But zlib1.dll is a dynamic link library (that's what DLL stands for!), so you can't link it statically. The first thing you need to do is find a static version of this library. On windows, it will normally end with the .lib extension.

I'm not familiar with cmake, so I'll let someone else answer the part of the question about how to make cmake use the static library, once you have both.

Tyler McHenry
How will you do if cmake is not required?
httpinterpret
Depends then on your compiler.
Tyler McHenry
+1  A: 

Sorry there is no way to mix it. Either you must compile and link statically or dynamically. I tried it - it does not work.

So if libpng.dll needs a zlib.dll you can't turn zlib into a static library. You have to also compile libpng as a static library.

I've done this a few times, the makefiles from PNG, ZLIB, (and also the JPEG, TIFF image format libraries) are pretty good. If you need more then 30min to figure out what to do, you should look at it as a good training on your C makefile skills.

Lothar
I don't know whether if zlib1.dll is linked by `LoadLibrary` or a load library.If the latter,then it can be fixed.
httpinterpret