c++ cuda trouble I'm having trouble getting c++ libraries to work with cuda

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

check your additonal dependencies for linking , have u added winmm.lib ?

it usually works once u done that !!

I added winmm.lib and it didn’t fix anything. Do you have any other suggestions?

sounds like you’re linking some things as /MT and some as /MTd. make sure they are the same…

where would I check?

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)

I had the same problem,

Try adding LIBCMT to Properties:Linker:Input:Ignore Specific Library.

Btw, ignoring LIBCMTD doesn’t seem to help.

this didn’t work but thanks for trying

Yeah, maybe your .cu files are being linked against debug stuff and your .cpp files aren’t, or vice versa?

I have the same problem. How can I specify which library to use for CUDA compiler?

Always having the problem or just in device emulation mode?

In device emulation mode only.

Cuda 2.2 cant do c++ with device emulation mode, so you are SOL. Supposedly this has been fixed in 2.3.

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.

Seems like the problem has been solved.

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.