# CUDA2 device emulation link error

**URL:** <https://forums.developer.nvidia.com/t/cuda2-device-emulation-link-error/3817>\
**Category:** CUDA Programming and Performance\
**Created:** [May 23, 2008, 5:22pm UTC](https://forums.developer.nvidia.com/t/cuda2-device-emulation-link-error/3817 "2008-05-23T17:22:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![santyhyammer](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@santyhyammer](https://forums.developer.nvidia.com/u/santyhyammer)\
**Post date:** [May 23, 2008, 5:22pm UTC](https://forums.developer.nvidia.com/t/cuda2-device-emulation-link-error/3817/1 "2008-05-23T17:22:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![santyhyammer](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@santyhyammer](https://forums.developer.nvidia.com/u/santyhyammer)\
**Post date:** [May 23, 2008, 9:31pm UTC](https://forums.developer.nvidia.com/t/cuda2-device-emulation-link-error/3817/2 "2008-05-23T21:31:20Z")

</div>

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 )

---

<div class="post-metadata">

**Author:** ![yezariael](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@yezariael](https://forums.developer.nvidia.com/u/yezariael)\
**Post date:** [July 4, 2008, 12:48pm UTC](https://forums.developer.nvidia.com/t/cuda2-device-emulation-link-error/3817/3 "2008-07-04T12:48:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Raphael](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Raphael](https://forums.developer.nvidia.com/u/Raphael)\
**Post date:** [September 4, 2008, 10:17am UTC](https://forums.developer.nvidia.com/t/cuda2-device-emulation-link-error/3817/4 "2008-09-04T10:17:16Z")

</div>

> [@](#):
>
> 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.
> 
> [snapback]405039[/snapback]

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

---

<div class="post-metadata">

**Author:** ![PaddyH](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@PaddyH](https://forums.developer.nvidia.com/u/PaddyH)\
**Post date:** [October 21, 2008, 3:11pm UTC](https://forums.developer.nvidia.com/t/cuda2-device-emulation-link-error/3817/5 "2008-10-21T15:11:33Z")

</div>

> [@](#):
>
> I’ve got the same problem. Is there a way to compile DLLs with the deviceemu flag?
> 
> [snapback]435251[/snapback]

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

Did you find any solutions?

---

<div class="post-metadata">

**Author:** ![tasora](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/tasora/32/400725_2.png) [@tasora](https://forums.developer.nvidia.com/u/tasora)\
**Post date:** [November 27, 2008, 9:20pm UTC](https://forums.developer.nvidia.com/t/cuda2-device-emulation-link-error/3817/6 "2008-11-27T21:20:51Z")

</div>

…same problem here… (with new Cuda 2.1)

Any hints?

> [@](#):
>
> Me too. I get the same C2201 errors when trying to debug a kernel.
> 
> Did you find any solutions?

A.Tasora
