CUDA 4.0 RC linking error on MSVC and dynamics runtime libraries /MD bug in nvcc?

Hi all,

this post is following http://forums.nvidia.com/index.php?showtopic=194944 and https://code.google.com/p/thrust/issues/detail?id=321&can=1&q=MD

As soon as a Thrust’s header file is included in a Cuda 4.0 project (no need to call a function), the compiler gives warnings and the linker gives errors (sorry for the french output!)

For my basic testing, I used the Marching cubes example delivered with the cuda SDK.

  • cuda 3.2 + thrust 1.3 -> no problem in both /MT and /MD

  • cuda 3.2 + thrust 1.4 -> no problem in both /MT and /MD

  • cuda 4.0 + thrust 1.4 -> no problem in /MT (default)

                      -> compilation warnings + link errors in /MD
    

Note that the runtime library option has been modified and is similar in ALL .cpp and .cu files (actually 2 files in the Marching Cubes example)

I am suspecting a bug in nvcc. I don’t think it comes directly from Thrust but it could come from the way Thrust is including std files.

What do you think ? Have you an idea on how to compile with the /MD option?

– pium

3>marchingCubes_kernel.cu

3>tmpxft_00001004_00000001-6_marchingCubes_kernel.compute_10.cudafe1.cpp

3>tmpxft_00001004_00000001-23_marchingCubes_kernel.compute_10.ii

3>c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocinfo(193) : warning C4251: 'std::_Locinfo::_Days' : class 'std::basic_string<_Elem,_Traits,_Ax>' nécessite une interface DLL pour être utilisé(e) par les clients de class 'std::_Locinfo'

3>        with

3>        [

3>            _Elem=char,

3>            _Traits=std::char_traits<char>,

3>            _Ax=std::allocator<char>

3>        ]

3>c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocinfo(194) : warning C4251: 'std::_Locinfo::_Months' : class 'std::basic_string<_Elem,_Traits,_Ax>' nécessite une interface DLL pour être utilisé(e) par les clients de class 'std::_Locinfo'

3>        with

3>        [

3>            _Elem=char,

3>            _Traits=std::char_traits<char>,

3>            _Ax=std::allocator<char>

3>        ]

3>c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocinfo(195) : warning C4251: 'std::_Locinfo::_Oldlocname' : class 'std::basic_string<_Elem,_Traits,_Ax>' nécessite une interface DLL pour être utilisé(e) par les clients de class 'std::_Locinfo'

3>        with

3>        [

3>            _Elem=char,

3>            _Traits=std::char_traits<char>,

3>            _Ax=std::allocator<char>

3>        ]

3>c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocinfo(196) : warning C4251: 'std::_Locinfo::_Newlocname' : class 'std::basic_string<_Elem,_Traits,_Ax>' nécessite une interface DLL pour être utilisé(e) par les clients de class 'std::_Locinfo'

3>        with

3>        [

3>            _Elem=char,

3>            _Traits=std::char_traits<char>,

3>            _Ax=std::allocator<char>

3>        ]

3>c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocale(245) : warning C4251: 'std::locale::_Locimp::_Name' : class 'std::basic_string<_Elem,_Traits,_Ax>' nécessite une interface DLL pour être utilisé(e) par les clients de class 'std::locale::_Locimp'

3>        with

3>        [

3>            _Elem=char,

3>            _Traits=std::char_traits<char>,

3>            _Ax=std::allocator<char>

3>        ]
1>------ Début de la génération : Projet : marchingCubes, Configuration : Release Win32 ------

1>Édition des liens en cours...

1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) déjà défini(e) dans marchingCubes_kernel.cu.obj

1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) déjà défini(e) dans marchingCubes_kernel.cu.obj

1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator=(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??4?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@ABV01@@Z) déjà défini(e) dans marchingCubes_kernel.cu.obj

1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator=(char const *)" (??4?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@PBD@Z) déjà défini(e) dans marchingCubes_kernel.cu.obj

1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ) déjà défini(e) dans marchingCubes_kernel.cu.obj

1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) déjà défini(e) dans marchingCubes_kernel.cu.obj

1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) déjà défini(e) dans marchingCubes_kernel.cu.obj

1>../../bin/win32/Release/marchingCubes.exe : fatal error LNK1169: un ou plusieurs symboles définis à différentes reprises ont été rencontrés

1>Le journal de génération a été enregistré à l'emplacement "file://c:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.0\C\src\marchingCubes\Release\BuildLog.htm"

1>marchingCubes - 8 erreur(s), 0 avertissement(s)

========== Génération : 0 a réussi, 1 a échoué, 2 mis à jour, 0 a été ignoré ==========

Hi all,

I am new to CUDA. Earlier I had been using VS2005 with CUDA Toolkit 3.2. I used a downloaded a tool called “CUDA_VS_Wizard_W32.2.0” and so was able to neatly put things together and run some developed codes.

Yesterday, I downloaded CUDA Toolkit 4.0 RC and tried to configure it with VS2010. All Linkage directories are probably taken care. I wrote a simple test code (that I had earlier tested with CUDA 3.2 + VS2005). Some how I get a linking error which I am totally unable to comprehend. The Error vanishes if I comment the call to HelloCUDA. Please Help. I seem to be in soup

Code:
global void HelloCUDA(char* result, int num)
{
int i = 0;
char p_HelloCUDA = “Hello CUDA!”;
for(i = 0; i < num; i++) {
result[i] = p_HelloCUDA[i];
}
}
int main(int argc, char* argv)
{
char Print[20];
HelloCUDA(&Print[0], 11);
printf("%s\n", Print);
return 0;
}

Error:
1>------ Build started: Project: FirstApp, Configuration: Release Win32 ------
1> Compiling CUDA source file FirstApp.cu…
1>
1> D:\Programs\VS2010\CUDA\FirstApp>“C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\bin\nvcc.exe” -gencode=arch=compute_10,code=“sm_10,compute_10” --use-local-env --cl-version 2010 -ccbin “C:\Program Files\Microsoft Visual Studio 10.0\VC\bin” -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include" --keep-dir “Release” -maxrregcount=32 --machine 32 --compile -Xcompiler "/EHsc /nologo /Od /Zi /MD " -o “Release\FirstApp.cu.obj” “D:\Programs\VS2010\CUDA\FirstApp\FirstApp.cu”

1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA 4.0.targets(267,3): error MSB3721: The command ““C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\bin\nvcc.exe” -gencode=arch=compute_10,code=“sm_10,compute_10” --use-local-env --cl-version 2010 -ccbin “C:\Program Files\Microsoft Visual Studio 10.0\VC\bin” -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include” --keep-dir “Release” -maxrregcount=32 --machine 32 --compile -Xcompiler “/EHsc /nologo /Od /Zi /MD " -o “Release\FirstApp.cu.obj” “D:\Programs\VS2010\CUDA\FirstApp\FirstApp.cu”” exited with code 2.

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Regards

Harash

Please, could someone try to compile the Marching cubes example with /MD to ensure I am not crazy and it comes from nvcc !
Thanks…

Good news, you are not alone with this problem. Tried compiling Marching cubes as directed and got the same error. I noticed the problem when trying to convert from cudpp use to thrust with CUDA RC 4.0 (Thrust 1.4) and was directed here by google. Compiling with VS 2008 on a x64 machine for Win32. So far, I found no solution.

ok, thanks, I’ll post it in the cuda bugtracker.

Hi,
I do have the same problem, but I use a radix sort example from 3.2 with it’s cudpp provided with sdk.
All of it compile fine, but doesn’t want to link :(
I don’t really know what this ‘bugtracker’ is, but do you have any information. Has it been resolved ?

Thank you,
Greg

You can find the bug tracker in the NVIDIA developer section (http://nvdeveloper.nvidia.com/). However, ‘Current bugs’ seems to return only empty search results. Where does one submit bug reports for the bug tracker itself…? :-)

@pium: Could you maybe post a follow up here once you have any news regarding this bug?

In NVIDIA’s system, bug reports are private. You can see only your own bug reports, not the bug reports of others.

In the same place. On the left of the developer portal is a “Bug report” link.

Still true in CUDA 4.0 RC2 and still open in the bugtracker :(

the new cudafe++ seems to be buggy; the one from SDK 3.2 can also be used for 4.0. Just copy to the appropriate directory.

Thanks for that idea! Somehow it never occured to me to use the old exe…

This issue should be resolved in CUDA 4.0 final.

In CUDA4.0, the link error doesn’t occur. It may be fixed. :)

I confirm it is corrected :D

Thanks!