CUDA2 device emulation link error

I am trying to compile a kernel in VS2005 using device emulation:
(CUDA_BIN_PATH)\nvcc.exe -ccbin "(VCInstallDir)bin" -deviceemu -c -D_DEBUG -DWIN32 -D_CONSOLE -D_MBCS -Xcompiler /EHsc,/W3,/nologo,/Wp64,/Od,/Zi,/RTC1,/MDd -I"(CUDA_INC_PATH)" -I./ -I../../common/inc -o (PlatformName)$(ConfigurationName)$(InputName).obj $(InputPath)

But I got these compilation errors:
1>cudaKernels.cu
1>g:\cuda2\include\common_functions.h(56): warning: dllexport/dllimport conflict
1> with “clock” (declared at line 176 of
1> “G:/vs2k5/VC/bin/…\INCLUDE\time.h”); dllimport/dllexport dropped
1>g:\cuda2\include\common_functions.h(56): warning: dllexport/dllimport conflict
1> with “clock” (declared at line 176 of
1> “G:/vs2k5/VC/bin/…\INCLUDE\time.h”); dllimport/dllexport dropped

1>g:\cuda2\include\math_functions.h(96) : error C2201: ‘__cuda_sinf’ : must have external linkage in order to be exported/imported
1>g:\cuda2\include\math_functions.h(101) : error C2201: ‘__cuda_cosf’ : must have external linkage in order to be exported/imported
1>g:\cuda2\include\math_functions.h(111) : error C2201: ‘__cuda_tanf’ : must have external linkage in order to be exported/imported
1>g:\cuda2\include\math_functions.h(116) : error C2201: ‘__cuda_sqrtf’ : must have external linkage in order to be exported/imported
1>g:\cuda2\include\math_functions.h(146) : error C2201: ‘__cuda_log10f’ : must have external linkage in order to be exported/imported
1>g:\cuda2\include\math_functions.h(151) : error C2201: ‘__cuda_logf’ : must have external linkage in order to be exported/imported
1>g:\cuda2\include\math_functions.h(159) : error C2201: ‘__cuda_floor’ : must have external linkage in order to be exported/imported
1>g:\cuda2\include\math_functions.h(161) : error C2201: ‘__cuda_floorf’ : must have external linkage in order to be exported/imported
1>g:\cuda2\include\math_functions.h(166) : error C2201: ‘__cuda_expf’ : must have external linkage in order to be exported/imported
1>g:\cuda2\include\math_functions.h(171) : error C2201: ‘__cuda_coshf’ : must have external linkage in order to be exported/imported
1>g:\cuda2\include\math_functions.h(176) : error C2201: ‘__cuda_sinhf’ : must have external linkage in order to be exported/imported
1>g:\cuda2\include\math_functions.h(181) : error C2201: ‘__cuda_tanhf’ : must have external linkage in order to be exported/imported
1>g:\cuda2\include\math_functions.h(199) : error C2201: ‘__cuda_ldexp’ : must have external linkage in order to be exported/imported
1>g:\cuda2\include\math_functions.h(224) : error C2201: ‘__cuda_frexp’ : must have external linkage in order to be exported/imported
1>g:\cuda2\include\math_functions.h(264) : error C2201: ‘__cuda_ceil’ : must have external linkage in order to be exported/imported
1>g:\cuda2\include\math_functions.h(266) : error C2201: ‘__cuda_ceilf’ : must have external linkage in order to be exported/imported
1>g:\cuda2\include\math_functions.h(281) : error C2201: ‘__cuda_atan2f’ : must have external linkage in order to be exported/imported
1>g:\cuda2\include\math_functions.h(286) : error C2201: ‘__cuda_atanf’ : must have external linkage in order to be exported/imported
1>g:\cuda2\include\math_functions.h(291) : error C2201: ‘__cuda_asinf’ : must have external linkage in order to be exported/imported
1>g:\cuda2\include\math_functions.h(296) : error C2201: ‘__cuda_acosf’ : must have external linkage in order to be exported/imported
1>g:\cuda2\include\math_functions.h(299) : error C2201: ‘__cuda_hypot’ : must have external linkage in order to be exported/imported
1>g:\cuda2\include\math_functions.h(311) : error C2201: ‘__cuda_powf’ : must have external linkage in order to be exported/imported
1>g:\cuda2\include\math_functions.h(314) : error C2201: ‘__cuda_modf’ : must have external linkage in order to be exported/imported
1>g:\cuda2\include\math_functions.h(316) : error C2201: ‘__cuda_modff’ : must have external linkage in order to be exported/imported
1>g:\cuda2\include\math_functions.h(321) : error C2201: ‘__cuda_fmodf’ : must have external linkage in order to be exported/imported
1>g:\cuda2\include\math_functions.h(1110) : error C2491: ‘__cuda_ceilf’ : definition of dllimport function not allowed
1>g:\cuda2\include\math_functions.h(1115) : error C2491: ‘__cuda_floorf’ : definition of dllimport function not allowed
1>g:\cuda2\include\math_functions.h(1120) : error C2491: ‘__cuda_sqrtf’ : definition of dllimport function not allowed
1>g:\cuda2\include\math_functions.h(1735) : error C2491: ‘__cuda_sinf’ : definition of dllimport function not allowed
1>g:\cuda2\include\math_functions.h(1746) : error C2491: ‘__cuda_cosf’ : definition of dllimport function not allowed
1>g:\cuda2\include\math_functions.h(1774) : error C2491: ‘__cuda_tanf’ : definition of dllimport function not allowed
1>g:\cuda2\include\math_functions.h(1808) : error C2491: ‘__cuda_expf’ : definition of dllimport function not allowed
1>g:\cuda2\include\math_functions.h(1830) : error C2491: ‘__cuda_coshf’ : definition of dllimport function not allowed
1>g:\cuda2\include\math_functions.h(1843) : error C2491: ‘__cuda_sinhf’ : definition of dllimport function not allowed
1>g:\cuda2\include\math_functions.h(1868) : error C2491: ‘__cuda_tanhf’ : definition of dllimport function not allowed
1>g:\cuda2\include\math_functions.h(1892) : error C2491: ‘__cuda_atan2f’ : definition of dllimport function not allowed
1>g:\cuda2\include\math_functions.h(1929) : error C2491: ‘__cuda_atanf’ : definition of dllimport function not allowed
1>g:\cuda2\include\math_functions.h(1965) : error C2491: ‘__cuda_asinf’ : definition of dllimport function not allowed
1>g:\cuda2\include\math_functions.h(1982) : error C2491: ‘__cuda_acosf’ : definition of dllimport function not allowed
1>g:\cuda2\include\math_functions.h(1999) : error C2491: ‘__cuda_logf’ : definition of dllimport function not allowed
1>g:\cuda2\include\math_functions.h(2010) : error C2491: ‘__cuda_log10f’ : definition of dllimport function not allowed
1>g:\cuda2\include\math_functions.h(2360) : error C2491: ‘__cuda_modff’ : definition of dllimport function not allowed
1>g:\cuda2\include\math_functions.h(2382) : error C2491: ‘__cuda_fmodf’ : definition of dllimport function not allowed
1>g:\cuda2\include\math_functions.h(2951) : error C2491: ‘__cuda_powf’ : definition of dllimport function not allowed
1>g:\cuda2\include\math_functions_dbl_ptx1.h(91) : error C2491: ‘__cuda_ceil’ : definition of dllimport function not allowed
1>g:\cuda2\include\math_functions_dbl_ptx1.h(101) : error C2491: ‘__cuda_floor’ : definition of dllimport function not allowed
1>g:\cuda2\include\math_functions_dbl_ptx1.h(226) : error C2491: ‘__cuda_hypot’ : definition of dllimport function not allowed
1>g:\cuda2\include\math_functions_dbl_ptx1.h(256) : error C2491: ‘__cuda_ldexp’ : definition of dllimport function not allowed
1>g:\cuda2\include\math_functions_dbl_ptx1.h(271) : error C2491: ‘__cuda_frexp’ : definition of dllimport function not allowed
1>g:\cuda2\include\math_functions_dbl_ptx1.h(276) : error C2491: ‘__cuda_modf’ : definition of dllimport function not allowed

If I remove the “-deviceemu” all works ok. What I need to do to compile it using device emulation pls? I’m trying to compile a C++ x64 DLL btw.

If I change the /MDd by /MTd it compiles… but like I use a Multithread Debug DLL model I could get some C CRT problems…

Btw, you should provide multiple libraries:

x86
cuda_mt_x86.lib -> multithreaded static
cuda_mtd_x86.lib -> multithreaded debug static
cuda_md_x86.lib -> multithreaded DLL
cuda_mdd_x86.lib -> multithreaded debug DLL

x64
cuda_mt_x64.lib -> multithreaded static
cuda_mtd_x64.lib -> multithreaded debug static
cuda_md_x64.lib -> multithreaded DLL
cuda_mdd_x64.lib -> multithreaded debug DLL

for VS2003, VS2005 and VS2008 ( they use different CRTs )
And package the x64 and x86 version inside the same toolkit/sdk… so I can cross compile without having to install 4 different toolkits…(vista x64, vista x32, winxp 32, winxp 64 )

So you solved the problem by compiling the libraries with the specific settings yourself?

And if yes, how did you compile it yourself, as I cannot find the sources for the libraries.

I’ve got the same problem. Is there a way to compile DLLs with the deviceemu flag?

Me too. I get the same C2201 errors when trying to debug a kernel.

Did you find any solutions?

…same problem here… (with new Cuda 2.1)

Any hints?

A.Tasora