I have a Visual Studio 2010 C++ project that links statically to tinyxmlSTL 2.5.5 (tinyxmlSTL.lib) and zlib 1.2.7. (zlibstat.lib). There are 4 builds in total covering both x86 and x64 as well as Debug and Release.
All combinations produce working builds except for Release x64 which gets a bunch of errors like this:
MSVCRT.lib(MSVCR100.dll) : error LNK2005: free already defined in LIBCMT.lib(free.obj)
…and a single warning:
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
If I add /NODEFAULTLIB:MSVCRT to linker options for the application then I get this:
zlibstat.lib(ioapi.obj) : error LNK2001: unresolved external symbol __imp__ftelli64
zlibstat.lib(ioapi.obj) : error LNK2001: unresolved external symbol __imp__fseeki64
Basically, all the projects (app and two libs) are set to use Multi-threaded (/MT) option in Release builds and yet x86 builds just fine while x64 suffers from above issues.
Any help or idea is highly appreciated.
You need to double check your settings for x64. One of the projects is using the
/MDflag rather than/MT.As per the MSVC docs, The MSVCRT.lib is invoked by using
/MD.EDIT :
As per your comments, it sounds like zlib is the likely culprit.
zlib has both a static and dll version, but both of these use the
/MDflag by default, so unless you changed that while building zlib – that’s your issue.To build zlib using
/MT:If you’ve not already done so, install CMake
Download and extract zlib to e.g.
C:\devel. The download links are about halfway down the homepage. Currently this provides zlib version 1.2.7.To work around this CMake bug, add
to the end of C:\devel\zlib-1.2.7\CMakeLists.txt
In a VS10 command prompt,
cd C:\devel\zlib-1.2.7cmake -H. -Bbuild -G"Visual Studio 10 Win64"This gets you a VS sloution C:\devel\zlib-1.2.7\build\zlib.sln which you can open. Change the settings for the “zlibstatic” target to
/MTand/MTdfor Release and Debug respectively.Building each will yield zlibstatic.lib in a subdirectory of build; either “Release” or “Debug”.