httpinterpret
httpinterpret

Reputation: 6709

How do I merge zlib1.dll into my executable in C?

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)

Upvotes: 0

Views: 994

Answers (2)

Lothar
Lothar

Reputation: 13067

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.

Upvotes: 1

Tyler McHenry
Tyler McHenry

Reputation: 76640

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.

Upvotes: 1

Related Questions