matrixMul compiles with default /MT but not with /MD. Bug? Using VS2008 under 64 bit Windows 7


I opened the Visual Studio 2008 project of the SDK “matrixMul” and I didn’t get any issue to compile it with the default options (I’m using CUDA 4.0 under windows 7 64 bits). But if I change the runTime library flag from “/MT” to “/MD” (project’s properties -> C/C++ -> Code Generation -> Runtime Library), I got the following errors:

Error	1	error LNK2005: "private: __cdecl type_info::type_info(class type_info const &)" (??0type_info@@AEAA@AEBV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)	MSVCRTD.lib

Error	2	error LNK2005: "private: class type_info & __cdecl type_info::operator=(class type_info const &)" (??4type_info@@AEAAAEAV0@AEBV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)	MSVCRTD.lib

Error	4	fatal error LNK1169: one or more multiply defined symbols found	c:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.0\C\bin\win64\Debug\matrixMul.exe

It looks similar to this other topic including Thrust: But at the end of the topic they say that the issue was fixed in CUDA 4.0 (final). So I guess my question is why it’s not possible to compile an SDK example with /MD ? Is it a desired behaviour or is there a bug in nvcc? Since we use the flag /MD in a big project I’m wondering if I will be able to use CUDA 4.0 within this project.

Ok, so for the record (it might interest someone one day, although I doubt it), I found the fix. I forgot to compile one of the libraries used by matrixMul with /MD. By default, CUBLAS, CUTIL, SHRUTILS, etc. are compiled with /MT. They all need to be compiled with /MD if matrixMul is compiled in /MD.