title: Linker errors using MySQL Connector C++ lib I built in Visual Studio 2013
body: <h2>Summary</h2>
  
  <p>AFAICT, the only pre-built <a href="http://dev.mysql.com/downloads/connector/cpp/" rel="nofollow">Connector/C++ library</a> that MySQL provides for Windows was built using Visual Studio 2010. I'm using Visual Studio 2013, so I need to build from source. I want to use the static library.</p>
  
  <p>Below is a rough description of the steps I took. I am able to build the library (<code>mysqlcppconn-static.lib</code>), and I can add it as a dependency and <code>#include</code> headers my project. But once I try to actually use the library, I get a whole bunch of linker errors.</p>
  
  <p>I played with the project properties, but I'm still stuck. How can I get this to work?</p>
  
  <h2>Details</h2>
  
  <h3>Project/Solution Construction Steps</h3>
  
  <ol>
  <li><p>Use <a href="https://cmake.org/" rel="nofollow"><code>cmake</code></a> for Windows with the <code>-DMYSQLCLIENT_STATIC_LINKING=true</code> and <code>-G "Visual Studio 12 2013"</code> options to create the project and solution files. Include <code>-D</code> parameters with paths for boost and the pre-built <code>mysql-connector-c-6.1.6-win32</code>.</p></li>
  <li><p>Open MYSQLCPPCONN.sln in Visual Studio, and build the mysqlcppconn-static project.</p></li>
  <li><p>Create a new VS solution and console application project in which I'll use the Connector/C++.</p></li>
  <li><p>Extract the pre-built Connector/C++ library .zip file, replace <code>mysqlcppconn-static.lib</code> with those I built (Debug &amp; Release), and setup paths accordingly.</p></li>
  <li><p>Configuration Properties --> C/C++ --> Preprocessor --> Preprocessor Definitions: add <code>CPPCONN_PUBLIC_FUNC=</code>.</p></li>
  </ol>
  
  <h3>Linker Errors Summary</h3>
  
  <pre><code>error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2'
  error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug'
  warning LNK4049: locally defined symbol _memmove (et al) imported
  warning LNK4217: locally defined symbol _memmove imported in function...
  error LNK2001: unresolved external symbol __imp___CrtDbgReportW (et al)
  </code></pre>
  
  <h3>Project Properties</h3>
  
  <p>I've been playing with the project properties in <code>mysqlcppconn-static</code>, and in my project that uses the library, trying to get them to match, but these errors persist.</p>
  
  <p>Here are some potentially relevant project properties that are set identically in both projects:</p>
  
  <pre><code>Configuration Properties --&gt; C/C++ --&gt; Code Generation
    --&gt; Basic Runtime Checks
          Debug   - /RTC1
          Release - Default
    --&gt; Runtime Library
          Debug   - Multi-threaded Debug DLL (/MDd)
          Release - Multi-threaded DLL (/MD)
  </code></pre>
  
  <p>And in my project (which uses the connector), I have this linker property:</p>
  
  <pre><code>Configuration Properties --&gt; Linker --&gt; Input --&gt; Ignore Specific Default Libraries
          Debug   - MSVCRTD.lib
          Release - MSVCRT.lib
  </code></pre>
  
  <hr>
  
  <h3>More of the Mess of Linker Errors</h3>
  
  <pre><code>1&gt;mysqlcppconn-static.lib(net_serv.obj)                        : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in useMySQLConnectorCpp.obj
  1&gt;mysqlcppconn-static.lib(net_serv.obj)                        : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug' in useMySQLConnectorCpp.obj
  1&gt;mysqlcppconn-static.lib(plugin_client.obj)                   : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in useMySQLConnectorCpp.obj
  1&gt;mysqlcppconn-static.lib(plugin_client.obj)                   : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug' in useMySQLConnectorCpp.obj
  [snip]
  1&gt;mysqlcppconn-static.lib(mysql_native_statement_wrapper.obj)  : warning LNK4049: locally defined symbol _memmove imported
  1&gt;mysqlcppconn-static.lib(mysql_art_rset_metadata.obj)         : warning LNK4049: locally defined symbol _memmove imported
  [snip]
  1&gt;mysqlcppconn-static.lib(mysql_native_connection_wrapper.obj) : warning LNK4217: locally defined symbol _memmove imported in function "public: __thiscall std::_String_alloc&lt;0,struct std::_String_base_types&lt;char,class std::allocator&lt;char&gt; &gt; &gt;::~_String_alloc&lt;0,struct std::_String_base_types&lt;char,class std::allocator&lt;char&gt; &gt; &gt;(void)" (??1?$_String_alloc@$0A@U?$_String_base_types@DV?$allocator@D@std@@@std@@@std@@QAE@XZ)
  1&gt;mysqlcppconn-static.lib(mysql_art_resultset.obj)             : warning LNK4049: locally defined symbol _memmove imported
  [snip]
  1&gt;mysqlcppconn-static.lib(mysql_client_api.obj)                : warning LNK4049: locally defined symbol _memmove imported
  1&gt;mysqlcppconn-static.lib(mysql_uri.obj)                       : warning LNK4217: locally defined symbol _memmove imported in function "public: void __thiscall std::_Wrap_alloc&lt;class std::allocator&lt;char&gt; &gt;::deallocate(char *,unsigned int)" (?deallocate@?$_Wrap_alloc@V?$allocator@D@std@@@std@@QAEXPADI@Z)
  1&gt;mysqlcppconn-static.lib(mysql_metadata.obj)                  : warning LNK4217: locally defined symbol _memmove imported in function __catch$?getProcedures@MySQL_ConnectionMetaData@mysql@sql@@UAEPAVResultSet@3@ABVSQLString@3@00@Z$0
  1&gt;mysqlcppconn-static.lib(mysql_warning.obj)                   : warning LNK4049: locally defined symbol _memmove imported
  1&gt;mysqlcppconn-static.lib(mysql_prepared_statement.obj)        : warning LNK4049: locally defined symbol _memmove imported
  1&gt;useMySQLConnectorCpp.obj                                     : warning LNK4217: locally defined symbol _memmove imported in function "public: static char * __cdecl std::char_traits&lt;char&gt;::move(char *,char const *,unsigned int)" (?move@?$char_traits@D@std@@SAPADPADPBDI@Z)
  [snip]
  1&gt;mysqlcppconn-static.lib(mysql_native_driver_wrapper.obj)     : warning LNK4049: locally defined symbol _memmove imported
  1&gt;mysqlcppconn-static.lib(mysql_native_statement_wrapper.obj)  : warning LNK4049: locally defined symbol __hypot imported
  1&gt;mysqlcppconn-static.lib(mysql_art_rset_metadata.obj)         : warning LNK4217: locally defined symbol __hypot imported in function "public: void __thiscall std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;::_Copy(unsigned int,unsigned int)" (?_Copy@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXII@Z)
  1&gt;mysqlcppconn-static.lib(mysql_resultset_metadata.obj)        : warning LNK4049: locally defined symbol __hypot imported
  [snip]
  1&gt;mysqlcppconn-static.lib(mysql_native_resultset_wrapper.obj)  : warning LNK4049: locally defined symbol __hypot imported
  1&gt;mysqlcppconn-static.lib(mysql_native_connection_wrapper.obj) : warning LNK4217: locally defined symbol __hypot imported in function "public: __thiscall std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;(class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const &amp;)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z)
  1&gt;mysqlcppconn-static.lib(mysql_art_resultset.obj)             : warning LNK4049: locally defined symbol __hypot imported
  [snip]
  1&gt;mysqlcppconn-static.lib(mysql_client_api.obj)                : warning LNK4049: locally defined symbol __hypot imported
  1&gt;mysqlcppconn-static.lib(mysql_uri.obj)                       : warning LNK4217: locally defined symbol __hypot imported in function "public: char * __thiscall std::_Wrap_alloc&lt;class std::allocator&lt;char&gt; &gt;::allocate(unsigned int)" (?allocate@?$_Wrap_alloc@V?$allocator@D@std@@@std@@QAEPADI@Z)
  1&gt;mysqlcppconn-static.lib(mysql_metadata.obj)                  : warning LNK4217: locally defined symbol __hypot imported in function __catch$?getUniqueNonNullableKeys@MySQL_ConnectionMetaData@mysql@sql@@QAEPAVResultSet@3@ABVSQLString@3@00@Z$0
  1&gt;mysqlcppconn-static.lib(mysql_warning.obj)                   : warning LNK4049: locally defined symbol __hypot imported
  1&gt;mysqlcppconn-static.lib(mysql_prepared_statement.obj)        : warning LNK4049: locally defined symbol __hypot imported
  1&gt;useMySQLConnectorCpp.obj                                     : warning LNK4217: locally defined symbol __hypot imported in function _hypot
  1&gt;mysqlcppconn-static.lib(mysql_driver.obj)                    : warning LNK4049: locally defined symbol __hypot imported
  1&gt;mysqlcppconn-static.lib(mysql_connection.obj)                : warning LNK4049: locally defined symbol __hypot imported
  1&gt;mysqlcppconn-static.lib(mysql_native_driver_wrapper.obj)     : warning LNK4049: locally defined symbol __hypot imported
  1&gt;mysqlcppconn-static.lib(mysql_client_api.obj)                : warning LNK4217: locally defined symbol __invalid_parameter imported in function "public: void __thiscall std::_Tree_alloc&lt;0,struct std::_Tree_base_types&lt;struct std::pair&lt;class sql::SQLString const ,class boost::shared_ptr&lt;class sql::mysql::NativeAPI::IMySQLCAPI&gt; &gt;,class std::allocator&lt;struct std::pair&lt;class sql::SQLString const ,class boost::shared_ptr&lt;class sql::mysql::NativeAPI::IMySQLCAPI&gt; &gt; &gt; &gt; &gt;::_Free_proxy(void)" (?_Free_proxy@?$_Tree_alloc@$0A@U?$_Tree_base_types@U?$pair@$$CBVSQLString@sql@@V?$shared_ptr@VIMySQLCAPI@NativeAPI@mysql@sql@@@boost@@@std@@V?$allocator@U?$pair@$$CBVSQLString@sql@@V?$shared_ptr@VIMySQLCAPI@NativeAPI@mysql@sql@@@boost@@@std@@@2@@std@@@std@@QAEXXZ)
  1&gt;mysqlcppconn-static.lib(mysql_art_resultset.obj)             : warning LNK4049: locally defined symbol __invalid_parameter imported
  1&gt;mysqlcppconn-static.lib(mysql_ps_resultset.obj)              : warning LNK4049: locally defined symbol __invalid_parameter imported
  1&gt;mysqlcppconn-static.lib(mysql_resultset.obj)                 : warning LNK4049: locally defined symbol __invalid_parameter imported
  1&gt;mysqlcppconn-static.lib(mysql_driver.obj)                    : warning LNK4217: locally defined symbol __invalid_parameter imported in function "public: bool __thiscall std::_Tree_const_iterator&lt;class std::_Tree_val&lt;struct std::_Tree_simple_types&lt;struct std::pair&lt;class sql::SQLString const ,class boost::shared_ptr&lt;class sql::mysql::MySQL_Driver&gt; &gt; &gt; &gt; &gt;::operator==(class std::_Tree_const_iterator&lt;class std::_Tree_val&lt;struct std::_Tree_simple_types&lt;struct std::pair&lt;class sql::SQLString const ,class boost::shared_ptr&lt;class sql::mysql::MySQL_Driver&gt; &gt; &gt; &gt; &gt; const &amp;)const " (??8?$_Tree_const_iterator@V?$_Tree_val@U?$_Tree_simple_types@U?$pair@$$CBVSQLString@sql@@V?$shared_ptr@VMySQL_Driver@mysql@sql@@@boost@@@std@@@std@@@std@@@std@@QBE_NABV01@@Z)
  1&gt;mysqlcppconn-static.lib(mysql_connection.obj)                : warning LNK4049: locally defined symbol __invalid_parameter imported
  1&gt;mysqlcppconn-static.lib(mysql_metadata.obj)                  : warning LNK4049: locally defined symbol __invalid_parameter imported
  1&gt;mysqlcppconn-static.lib(mysql_prepared_statement.obj)        : warning LNK4049: locally defined symbol __invalid_parameter imported
  1&gt;mysqlcppconn-static.lib(mysql_resultbind.obj)                : warning LNK4049: locally defined symbol ??0exception@std@@QAE@ABQBD@Z (public: __thiscall std::exception::exception(char const * const &amp;)) imported
  1&gt;mysqlcppconn-static.lib(mysql_resultset.obj)                 : warning LNK4049: locally defined symbol ??0exception@std@@QAE@ABQBD@Z (public: __thiscall std::exception::exception(char const * const &amp;)) imported
  [snip]
  1&gt;mysqlcppconn-static.lib(mysql_resultbind.obj)                : warning LNK4049: locally defined symbol ??0exception@std@@QAE@ABV01@@Z (public: __thiscall std::exception::exception(class std::exception const &amp;)) imported
  [snip]
  1&gt;mysqlcppconn-static.lib(mysql_resultbind.obj)                : warning LNK4049: locally defined symbol ??1exception@std@@UAE@XZ (public: virtual __thiscall std::exception::~exception(void)) imported
  1&gt;mysqlcppconn-static.lib(mysql_resultset.obj)                 : warning LNK4049: locally defined symbol ??1exception@std@@UAE@XZ (public: virtual __thiscall std::exception::~exception(void)) imported
  [snip]
  1&gt;mysqlcppconn-static.lib(mysql_connection.obj)                : warning LNK4217: locally defined symbol __strnicmp imported in function __catch$?prepareStatement@MySQL_Connection@mysql@sql@@UAEPAVPreparedStatement@3@ABVSQLString@3@@Z$0
  1&gt;mysqlcppconn-static.lib(mysql_connection.obj)                : warning LNK4217: locally defined symbol ?name@type_info@@QBEPBDPAU__type_info_node@@@Z (public: char const * __thiscall type_info::name(struct __type_info_node *)const ) imported in function "public: int * __thiscall sql::BaseVariantImpl::get&lt;int&gt;(void)const " (??$get@H@BaseVariantImpl@sql@@QBEPAHXZ)
  1&gt;mysqlcppconn-static.lib(mysql_uri.obj)                       : warning LNK4217: locally defined symbol _atoi imported in function "bool __cdecl sql::mysql::parseUri(class sql::SQLString const &amp;,class sql::mysql::MySQL_Uri &amp;)" (?parseUri@mysql@sql@@YA_NABVSQLString@2@AAVMySQL_Uri@12@@Z)
  1&gt;mysqlcppconn-static.lib(mysql_metadata.obj)                  : warning LNK4217: locally defined symbol _atoi imported in function __catch$?getColumnPrivileges@MySQL_ConnectionMetaData@mysql@sql@@UAEPAVResultSet@3@ABVSQLString@3@000@Z$0
  1&gt;mysqlcppconn-static.lib(mysql_metadata.obj)                  : warning LNK4217: locally defined symbol __snprintf imported in function __catch$?getImportedKeys@MySQL_ConnectionMetaData@mysql@sql@@UAEPAVResultSet@3@ABVSQLString@3@00@Z$0
  1&gt;mysqlcppconn-static.lib(mysql_art_resultset.obj)             : warning LNK4049: locally defined symbol __snprintf imported
  [snip]
  1&gt;mysqlcppconn-static.lib(mysql_metadata.obj)                  : warning LNK4217: locally defined symbol _tolower imported in function "public: int __thiscall sql::SQLString::caseCompare(class sql::SQLString const &amp;)const " (?caseCompare@SQLString@sql@@QBEHABV12@@Z)
  1&gt;mysqlcppconn-static.lib(mysql_prepared_statement.obj)        : warning LNK4217: locally defined symbol ??0exception@std@@QAE@ABQBDH@Z (public: __thiscall std::exception::exception(char const * const &amp;,int)) imported in function "public: __thiscall std::bad_alloc::bad_alloc(void)" (??0bad_alloc@std@@QAE@XZ)
  1&gt;mysqlcppconn-static.lib(mysql_debug.obj)                     : warning LNK4217: locally defined symbol _getenv imported in function "public: __thiscall sql::mysql::MySQL_DebugLogger::MySQL_DebugLogger(void)" (??0MySQL_DebugLogger@mysql@sql@@QAE@XZ)
  1&gt;mysqlcppconn-static.lib(mysql_debug.obj)                     : warning LNK4217: locally defined symbol _printf imported in function "public: void __thiscall sql::mysql::MySQL_DebugLogger::enter(class sql::mysql::MySQL_DebugEnterEvent const *)" (?enter@MySQL_DebugLogger@mysql@sql@@QAEXPBVMySQL_DebugEnterEvent@23@@Z)
  1&gt;mysqlcppconn-static.lib(mysql_debug.obj)                     : warning LNK4217: locally defined symbol _vprintf imported in function "public: void __cdecl sql::mysql::MySQL_DebugLogger::log_va(char const * const,char const * const,...)" (?log_va@MySQL_DebugLogger@mysql@sql@@QAAXQBD0ZZ)
  1&gt;mysqlcppconn-static.lib(mysql_debug.obj)                     : warning LNK4217: locally defined symbol _strstr imported in function "public: __thiscall sql::mysql::MySQL_DebugEnterEvent::MySQL_DebugEnterEvent(unsigned int,char const * const,char const * const,class boost::shared_ptr&lt;class sql::mysql::MySQL_DebugLogger&gt; const &amp;)" (??0MySQL_DebugEnterEvent@mysql@sql@@QAE@IQBD0ABV?$shared_ptr@VMySQL_DebugLogger@mysql@sql@@@boost@@@Z)
  1&gt;mysqlcppconn-static.lib(mysql_ps_resultset_metadata.obj)     : warning LNK4217: locally defined symbol _strstr imported in function "char * __cdecl std::_Allocate&lt;char&gt;(unsigned int,char *)" (??$_Allocate@D@std@@YAPADIPAD@Z)
  1&gt;mysqlcppconn-static.lib(mysql_resultset_metadata.obj)        : warning LNK4049: locally defined symbol _strstr imported
  1&gt;mysqlcppconn-static.lib(mysql_util.obj)                      : warning LNK4217: locally defined symbol _strtod imported in function "long double __cdecl sql::mysql::util::strtold(char const *,char * *)" (?strtold@util@mysql@sql@@YAOPBDPAPAD@Z)
  1&gt;mysqlcppconn-static.lib(mysql_art_resultset.obj)             : warning LNK4217: locally defined symbol __strtoi64 imported in function "public: __int64 __thiscall sql::mysql::MyVal::getInt64(void)" (?getInt64@MyVal@mysql@sql@@QAE_JXZ)
  1&gt;mysqlcppconn-static.lib(mysql_ps_resultset.obj)              : warning LNK4217: locally defined symbol __strtoi64 imported in function "public: __thiscall sql::SQLException::SQLException(class sql::SQLException const &amp;)" (??0SQLException@sql@@QAE@ABV01@@Z)
  1&gt;mysqlcppconn-static.lib(mysql_resultset.obj)                 : warning LNK4049: locally defined symbol __strtoi64 imported
  1&gt;mysqlcppconn-static.lib(mysql_art_resultset.obj)             : warning LNK4217: locally defined symbol __strtoui64 imported in function "public: unsigned __int64 __thiscall sql::mysql::MyVal::getUInt64(void)" (?getUInt64@MyVal@mysql@sql@@QAE_KXZ)
  1&gt;mysqlcppconn-static.lib(mysql_ps_resultset.obj)              : warning LNK4217: locally defined symbol __strtoui64 imported in function __unwindfunclet$??0SQLException@sql@@QAE@ABV01@@Z$0
  1&gt;mysqlcppconn-static.lib(mysql_resultset.obj)                 : warning LNK4049: locally defined symbol __strtoui64 imported
  1&gt;mysqlcppconn-static.lib(mysql_client_api.obj)                : error LNK2001: unresolved external symbol __imp___CrtDbgReportW
  1&gt;mysqlcppconn-static.lib(mysql_art_resultset.obj)             : error LNK2001: unresolved external symbol __imp___CrtDbgReportW
  [snip]
  1&gt;mysqlcppconn-static.lib(mysql_native_statement_wrapper.obj)  : error LNK2001: unresolved external symbol __imp___wassert
  1&gt;mysqlcppconn-static.lib(mysql_art_rset_metadata.obj)         : error LNK2001: unresolved external symbol __imp___wassert
  [snip]
  1&gt;mysqlcppconn-static.lib(mysql_uri.obj)                       : error LNK2019: unresolved external symbol __imp__memchr referenced in function "public: static char const * __cdecl std::char_traits&lt;char&gt;::find(char const *,unsigned int,char const &amp;)" (?find@?$char_traits@D@std@@SAPBDPBDIABD@Z)
  1&gt;mysqlcppconn-static.lib(mysql_metadata.obj)                  : error LNK2001: unresolved external symbol __imp__memchr
  1&gt;mysqlcppconn-static.lib(mysql_resultset.obj)                 : error LNK2019: unresolved external symbol __imp__div referenced in function "public: virtual __int64 __thiscall sql::mysql::MySQL_ResultSet::getInt64(unsigned int)const " (?getInt64@MySQL_ResultSet@mysql@sql@@UBE_JI@Z)
  </code></pre>