View Full Version : zlib and visual studio 2005

10-21-2008, 02:56 PM
Given my track record getting questions answered on here, I'm not holding my breath that anyone will reply to this. However, it can't hurt to ask.

I've run into a strange problem. I compiled zlib using the vs2005 project that comes with the source code into a static lib.

The static lib is zlib.lib while I also have the normal stub lib zdll.lib, for zlib1.dll that is available in compiled from from the zlib site.

I made a "Win32 Console" application and used the zlib.lib fine. I then made a "Win32 Project (Empty Project)" application and tried to use zlib.lib and it gave me the following error:
error LNK2005: _malloc already defined in LIBCMT.lib(malloc.obj) MSVCRT.lib (same again for _free).

I switched to the dll and it makes the problem go away but I'd really like to use the lib to get rid of the dll, to make distribution of the exe easier (it needs no other dlls at all).

Does anyone know how I can get rid of this error and use the static lib in my "Win32 Project"?

10-21-2008, 04:16 PM
Well what are the build option differences between the two projects? Considering the number of different options, it is hard to say which one is causing the issue without looking at them.

10-21-2008, 08:20 PM
I've been through trying to make them as close as possible to each other but it doesnt seem to be making a difference. I would have thought the linker settings would do it but they already are the same and it still doesn't work.

They were just the default VS2005 settings for "Win32 Console" and "Win32 Project" (with Empty Project set) and Console worked while Project didn't.