About .cu files: Getting tons of errors in VS2008

Hi,

I have just started to code with CUDA. I have a huge C++ project written in Visual Studio 2008 and I am trying to optimize a certain part of the code in the project. I just wanted to write a simple kernel for now and stored it in a seperate .cu file which I added among other .cpp files. CUDA rules, necessary libraries and include files are completely adjusted. The kernel is the following:

global void square(int* dataIN, int* dataOUT)
{
const unsigned int tid = threadIdx.x;
dataOUT[tid]=dataIN[tid]*dataIN[tid];
}

When I try to compile the whole project as this .cu file included in it; I get tons of errors:

1>LIBCMT.lib(tidtable.obj) : error LNK2005: __encode_pointer already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMT.lib(tidtable.obj) : error LNK2005: __decode_pointer already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMT.lib(invarg.obj) : error LNK2005: __invoke_watson already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMT.lib(crt0dat.obj) : error LNK2005: __amsg_exit already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMT.lib(crt0dat.obj) : error LNK2005: __initterm_e already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMT.lib(crt0dat.obj) : error LNK2005: _exit already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMT.lib(crt0dat.obj) : error LNK2005: __exit already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMT.lib(crt0dat.obj) : error LNK2005: __cexit already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMT.lib(mlock.obj) : error LNK2005: __unlock already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMT.lib(mlock.obj) : error LNK2005: __lock already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMT.lib(setlocal.obj) : error LNK2005: __configthreadlocale already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMT.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in MSVCRTD.lib(cinitexe.obj)
1>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in MSVCRTD.lib(cinitexe.obj)
1>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in MSVCRTD.lib(cinitexe.obj)
1>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in MSVCRTD.lib(cinitexe.obj)
1>LIBCMT.lib(hooks.obj) : error LNK2005: “void __cdecl terminate(void)” (?terminate@@YAXXZ) already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMT.lib(errmode.obj) : error LNK2005: ___set_app_type already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMT.lib(_ctype.obj) : error LNK2005: _isalpha already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMT.lib(_ctype.obj) : error LNK2005: _isspace already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMT.lib(_ctype.obj) : error LNK2005: _isalnum already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMT.lib(atox.obj) : error LNK2005: _atoi already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMT.lib(tolower.obj) : error LNK2005: _tolower already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LINK : warning LNK4098: defaultlib ‘MSVCRTD’ conflicts with use of other libs; use /NODEFAULTLIB:library
1>LINK : warning LNK4098: defaultlib ‘LIBCMT’ conflicts with use of other libs; use /NODEFAULTLIB:library
1>LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>D:\The_Project_TEZ_CUDA\Debug\The_Project_TEZ.exe : fatal error LNK1120: 1 unresolved externals

When I remove the kernel from the project, everything works just fine. This was just a “Hello World” trial with CUDA, I did not even call the kernel, just included in my project and hell is unleashed. What can be wrong? Please help me…

Thanks in advance

what #includes do you have in your .cu file?

Try right clicking on the .cu file -> properties -> CUDA C/C++ -> Host and then try some different settings under the “Runtime Library” like maybe “Multi-Threaded Debug(/MTd)”.