| Bug #40685 | Debug version of ODBC does not link to MS debug libraries | ||
|---|---|---|---|
| Submitted: | 13 Nov 2008 5:15 | Modified: | 29 Oct 2013 14:08 |
| Reporter: | Paul Harris | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | Connector / ODBC | Severity: | S2 (Serious) |
| Version: | 5.1.5r1144 | OS: | Windows |
| Assigned to: | Assigned Account | CPU Architecture: | Any |
| Tags: | cmake, msvc | ||
[13 Nov 2008 5:15]
Paul Harris
[13 Nov 2008 14:40]
MySQL Verification Team
Thank you for the bug report. C:\down\mysql-connector-odbc-5.1.5r1144>set MYSQL_DIR=C:\temp\mysql-5.0.67-win32 C:\down\mysql-connector-odbc-5.1.5r1144> cmake -G "Visual Studio 8 2005" -- Check for working C compiler: C:/Arquivos de programas/Microsoft Visual Studio 8/VC/bin/cl.exe -- Check for working C compiler: C:/Arquivos de programas/Microsoft Visual Studio 8/VC/bin/cl.exe -- works -- Check size of void* -- Check size of void* - done -- Check for working CXX compiler: C:/Arquivos de programas/Microsoft Visual Studio 8/VC/bin/cl.exe -- Check for working CXX compiler: C:/Arquivos de programas/Microsoft Visual Studio 8/VC/bin/cl.exe -- works -- MySQL Include dir: C:/temp/mysql-5.0.67-win32/include library dir: C:/temp/mysql-5.0.67-win32/lib/opt -- MySQL client libraries: mysqlclient;zlib;ws2_32 -- Checking if SQLColAttribute last arg is compatible with SQLLEN* - FALSE -- Checking if SQLColAttribute last arg is compatible with SQLPOINTER - FALSE -- Checking if SQLParamOptions() 2nd and 3rd arg is compatible with SQLULEN - FALSE -- Checking if SQLParamOptions() 2nd and 3rd arg is compatible with SQLUINTEGER - FALSE -- Configuring done -- Generating done -- Build files have been written to: C:/down/mysql-connector-odbc-5.1.5r1144 Release build success: Build log was saved at "file://c:\down\mysql-connector-odbc-5.1.5r1144\ALL_BUILD.dir\Release\BuildLog.htm" ALL_BUILD - 0 error(s), 0 warning(s) ========== Build: 29 succeeded, 0 failed, 1 up-to-date, 0 skipped ========== Below errors for Debug Build: Error 1 error LNK2005: _calloc already defined in LIBCMTD.lib(dbgheap.obj) LIBCMT.lib Warning 2 warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library myodbc-installer Error 3 fatal error LNK1169: one or more multiply defined symbols found C:\down\mysql-connector-odbc-5.1.5r1144\bin\Debug\myodbc-installer.exe 1 Error 4 error LNK2005: _calloc already defined in LIBCMTD.lib(dbgheap.obj) LIBCMT.lib Warning 5 warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library myodbc5S Error 6 fatal error LNK1169: one or more multiply defined symbols found C:\down\mysql-connector-odbc-5.1.5r1144\lib\Debug\myodbc5S.dll 1 Error 7 error LNK2005: _calloc already defined in LIBCMTD.lib(dbgheap.obj) LIBCMT.lib Warning 8 warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library myodbc5 Error 9 fatal error LNK1169: one or more multiply defined symbols found C:\down\mysql-connector-odbc-5.1.5r1144\lib\Debug\myodbc5.dll 1
[14 Nov 2008 17:07]
Jess Balint
Paul, Try running cmake with -DCMAKE_BUILD_TYPE=Debug -G"Visual Studio 8 2005".
[1 Dec 2008 7:20]
Tonci Grgin
Paul, please try what Jess suggests and provide feedback.
[1 Dec 2008 11:52]
Paul Harris
The suggestion from Jess does indeed work. (sorry for delay responding) I would of course prefer for it to be able to work via the cmake GUI in windows, but its not a killer problem now. thanks, Paul
[1 Dec 2008 12:09]
Tonci Grgin
Paul, no problem as long as things work. Tony, please document this. I think it's intended behaviour but you might want to check with Jess first.
[1 Dec 2008 19:09]
Jess Balint
You can also set the variable through the GUI. It's not required to use the command line. The rationale behind this is that the binary releases of MySQL include both lib/opt (release build) and lib/debug (debug build). Since the ODBC driver needs to link to only one of these we need to find the correct link path. If there's a way to delay this decision to when the build is actually done I'm not aware of it and would be happy to help get it implemented.
[2 Dec 2008 0:15]
Paul Harris
It can be done post-configuration. See how FindBoost.cmake does it: http://public.kitware.com/cgi-bin/viewcvs.cgi/Modules/FindBoost.cmake?root=CMake&view=mark... look for this bit: SET(Boost_${basename}_LIBRARIES optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG}) then when you link to ${Boost_datetime_LIBRARIES}, the builder (MSVC) should automatically figure out which library you want through the use of the optimized and debug keywords. So its giving cmake's target_link_libraries() both the debug and optimized library names. For a unix Makefile generator (which only supports 1 build type at a time), it'll lock in the appropriate library at the point of generation based on the build type. This is where my knowledge gets a bit fuzzy, for MSVC, its projects aren't restricted to one build type... So the optimized/debug versions should carry through and be configured within the MSVC project files.
[29 Oct 2013 14:08]
Bogdan Degtyariov
The problem is fixed. The debug version of Connector/ODBC uses /MDd flag to link against the debug runtime libraries. The release version uses /MD flag.
