I am trying to build a CUDA project under VS2010. I have the following files
main.cpp <- main program
kernel.cu <- file containg kernels
Inside kernel.cu file theres a wrapper function for the kernel, and some prints are done in this function using cout, clog and cerr. is included both in main.cpp and kernel.cu and I’m getting the following errors
msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::operator<<(class std::basic_ostream<char,struct std::char_traits<char> > & (__cdecl*)(class std::basic_ostream<char,struct std::char_traits<char> > &))" (??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z) already defined in teste.cu.obj
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: void __thiscall std::basic_ios<char,struct std::char_traits<char> >::setstate(int,bool)" (?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z) already defined in teste.cu.obj
...
and so on
I was able to realize that this error means that the symbols of are duplicated. In fact they are, one time compiled using vc100 and another time using nvcc. I was able to solve this problem changing the output form of nvcc to -cubin instead of -compile.
I was wondering what is the main difference between these options.
Does -compile flag makes nvcc to link the code on .cu files and -cubin generates the cuda obj files?