hello, all

When I compiled a sample which shows how to use zlib and is provided by
the official web site in VC7, the following errors occured.

Linking...
MSVCRT.lib(MSVCR71.dll) : error LNK2005: _malloc already defined in
LIBC.lib(malloc.obj)
MSVCRT.lib(MSVCR71.dll) : error LNK2005: _free already defined in
LIBC.lib(free.obj)
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other
libs; use /NODEFAULTLIB:library
Release/zlib_test1.exe : fatal error LNK1169: one or more multiply defined
symbols found

zlib just provide VC6 project of zlib, but I compliled it with VC7
successfully. I know msvcrt.lib and libc.lib are both provieded by VC. I
wanna know what might raise the above errors generally.

THANKS!

Re: link errors in using zlib by Igor

Igor
Sun Feb 05 09:09:17 CST 2006

"Bill Gates" <billgates@microsoft.com> wrote in message
news:Os7r9vjKGHA.2392@TK2MSFTNGP09.phx.gbl
> When I compiled a sample which shows how to use zlib and is
> provided by the official web site in VC7, the following errors
> occured.
> Linking...
> MSVCRT.lib(MSVCR71.dll) : error LNK2005: _malloc already defined in
> LIBC.lib(malloc.obj)

The static lib you use is built against static CRT whereas your project
is being built against CRT DLL (or the other way round). Make sure both
agree on the CRT flavor. Project | Settings | C/C++ | Code Generation |
Runtime Library
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925



Thanks by Bill

Bill
Sun Feb 05 20:25:09 CST 2006

Thanks :>

"Igor Tandetnik" <itandetnik@mvps.org>
OHLdgYmKGHA.2808@TK2MSFTNGP15.phx.gbl...
> "Bill Gates" <billgates@microsoft.com> wrote in message
> news:Os7r9vjKGHA.2392@TK2MSFTNGP09.phx.gbl
>> When I compiled a sample which shows how to use zlib and is
>> provided by the official web site in VC7, the following errors
>> occured.
>> Linking...
>> MSVCRT.lib(MSVCR71.dll) : error LNK2005: _malloc already defined in
>> LIBC.lib(malloc.obj)
>
> The static lib you use is built against static CRT whereas your project is
> being built against CRT DLL (or the other way round). Make sure both agree
> on the CRT flavor. Project | Settings | C/C++ | Code Generation | Runtime
> Library
> --
> With best wishes,
> Igor Tandetnik
>
> With sufficient thrust, pigs fly just fine. However, this is not
> necessarily a good idea. It is hard to be sure where they are going to
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
>