My program will not successfully compile in /MT (MultiThreaded) mode. It Compiles in /MD (MultiThreaded DLL). I want to be able to use both libcurl and boost in an application I will distribute with an installer.
Compiling in: MSVS2010
This is code to replicate my problem:
#include "stdafx.h"
#include "boost/regex.hpp"
#include "curl/curl.h"
int _tmain(int argc, _TCHAR* argv[])
{
CURL *curl;
curl = curl_easy_init();
return 0;
}
This is the warning I get if in /MD mode:
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs;
use /NODEFAULTLIB:library
If I try compiling in /MT mode I get:
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _calloc already defined in
LIBCMT.lib(calloc.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _realloc already defined in 开发者_Go百科LIBCMT.lib(realloc.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _free already defined in LIBCMT.lib(free.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _malloc already defined in LIBCMT.lib(malloc.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _strtoul already defined in LIBCMT.lib(strtol.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _memmove already defined in LIBCMT.lib(memmove.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _tolower already defined in LIBCMT.lib(tolower.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _strtol already defined in LIBCMT.lib(strtol.obj)
...
: fatal error LNK1169: one or more multiply defined symbols found
I want to compile in /MT mode so that others can run my finished program with out having MSVS installed or needing to download anything additional. I can include and dll or lib files needed by my app in the installer.
I could disable loading the 'MSVCRTD' default library, but then compiling the with boost fails.
These are my preprocessor definitions:
WIN32
_DEBUG
_CONSOLE
BUILDING_LIBCURL
HTTP_ONLY
These are my additional dependencies:
libcurl.lib
ws2_32.lib
winmm.lib
wldap32.lib
Does anyone know what I am doing wrong?
Thanks, William
Try setting nodefaultlib:libcmt.lib
in linker options in VC.
MSVCRT*D* LIBC*MT*.lib
flag compile the library differs from the flag compile the project (/MT,/MTD,/MD,/MDD)
Try to remove _DEBUG
from precompiler directives (i.e. build release version). The libraries you link into your application use a non-debug versions and your code links to debug-version. That's why you get linker error that symbols are multiply defined: it links both debug and non-debug versions of runtime libraries.
(As far as I understood you tried to statically link all the required libraries.)
Try building libCurl with rtlibcfg=static. This will build the /Mt static version of libCURL.
精彩评论