[CONC-174] unable to compile with /MD flag instead of /MT Created: 2016-04-18  Updated: 2016-04-18

Status: Open
Project: MariaDB Connector/C
Component/s: None
Affects Version/s: 2.2.2, 2.2.3
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Andy Li Assignee: Georg Richter
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Since revision 97, the CMake file forced the use of /MT instead of /MD. What's the reason for that?

It causes problem when I link the static lib to my program:

5>  mysql.c
5>LIBCMT.lib(dosmap.obj) : error LNK2005: __errno already defined in MSVCRT.lib(MSVCR100.dll)
5>LIBCMT.lib(tidtable.obj) : error LNK2005: __encoded_null already defined in MSVCRT.lib(MSVCR100.dll)
5>LIBCMT.lib(crtheap.obj) : error LNK2005: __malloc_crt already defined in MSVCRT.lib(MSVCR100.dll)
5>LIBCMT.lib(mlock.obj) : error LNK2005: __unlock already defined in MSVCRT.lib(MSVCR100.dll)
5>LIBCMT.lib(mlock.obj) : error LNK2005: __lock already defined in MSVCRT.lib(MSVCR100.dll)
5>LIBCMT.lib(winxfltr.obj) : error LNK2005: ___CppXcptFilter already defined in MSVCRT.lib(MSVCR100.dll)
5>LIBCMT.lib(crt0dat.obj) : error LNK2005: __initterm_e already defined in MSVCRT.lib(MSVCR100.dll)
5>LIBCMT.lib(crt0dat.obj) : error LNK2005: _exit already defined in MSVCRT.lib(MSVCR100.dll)
5>LIBCMT.lib(crt0dat.obj) : error LNK2005: __amsg_exit already defined in MSVCRT.lib(MSVCR100.dll)
5>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in MSVCRT.lib(cinitexe.obj)
5>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in MSVCRT.lib(cinitexe.obj)
5>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in MSVCRT.lib(cinitexe.obj)
5>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in MSVCRT.lib(cinitexe.obj)
5>     Creating library D:/Documents/workspace/neko/build/bin/mysql.lib and object D:/Documents/workspace/neko/build/bin/mysql.exp
5>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
5>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
5>LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
5>D:\Documents\workspace\neko\build\bin\mysql.ndll : fatal error LNK1120: 1 unresolved externals

According to this SO question, using /MD seems to be the best practice.

If you prefer /MT for whatever reason, there should be at least a way for users to change it back to /MD (e.g. add an option(USE_MD ...)). It is currently not easy since the CMakelists.txt uses "set(... FORCE)" which will overwrite any user changes of the CMAKE_C_FLAGS_*. My current solution is to patch the CMakelists.txt manually before compiling it.


Generated at Thu Feb 08 03:03:24 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.