I’m using visual studio 2005. My cuda parts compile fine when there isn’t any libraries like iostream or fstream but when I include them I get 26 errors like:
1>file.obj : warning LNK4075: ignoring ‘/EDITANDCONTINUE’ due to ‘/INCREMENTAL:NO’ specification
1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: _malloc already defined in LIBCMT.lib(malloc.obj)
1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __heap_alloc already defined in LIBCMT.lib(malloc.obj)
1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: _calloc already defined in LIBCMT.lib(calloc.obj)
I’m not using any precompiled headers.
If you know how to get all the C++ libraries to work in cuda please help
or more helpfully is there a template that I can download to create cuda programs with c++ because I got one from somebody on the forums and it is not very good (no offense)
Interestingly enough this happens to my emulator debug build only, release build seems to be ok. To me this looks like the problem should be solvable, I just need to find out how. My current guess is that there should be a way to tell the CUDA compiler which library to compile for.
The solution is: If, for example, you specify the use of multi-threaded debug libraries (compiler switch /MTd) for your C++ code then in emulator builds for your *.cu files the switch needs to be propagated from nvcc down to the underlying cl compiler via “-Xcompiler /MTd” option.