简体   繁体   中英

Visual Studio linker errors trying to use static lib in DLL (LNK2038, LNK2005)

In Visual Studio 2013, I am trying to use a static library (MySQL Connector/C) in another static library (say "MyConn"), and to use that (MyConn) in a DLL project. The static libraries build find, but attempting to build the DLL produces linker errors like these:

MyConn.lib(plugin_client.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in doit.obj
LIBCMTD.lib(dbgheap.obj) : error LNK2005: __CrtCheckMemory already defined in msvcrtd.lib(MSVCR120D.dll)

In project properties, Configuration Properties --> C/C++ --> Code Generation --> Runtime Library , all three projects have the same setting for their respective build types:

  • Debug - Multi-threaded Debug DLL (/MDd)
  • Release - Multi-threaded DLL (/MD)

What other settings might fix this?

Your doit.obj is linked with different MS runtime library than MyConn.lib. Check your project settings and make sure that runtime library is set to Multithreaded Debug or Multithreaded for both projects.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM