I am trying to get a CUDA program to link with a DLL using MSVC8, does anyone know how to do this?

I have compiled my code, but when I try and link it I get errors like

"msvcrt.lib(MSVCR80.dll) : error LNK2005: _exit already defined in LIBCMT.lib(crt


So, I tried the -shared option, which compiles fine, no complaints, but the resulting program says “EXE is not a valid Win32 application”.

I then tried --linkeroptions “MD” which results in an "Internal Compiler Error in C:\Program Files\Microsoft Visual Studio 8\VC\bin\cl.

exe. You will be prompted to send an error report to Microsoft later."

My current command line is:

CL is:

Microsoft ® 32-bit C/C++ Optimizing Compiler Version 14.00.50727.42 for 80x86

Copyright © Microsoft Corporation. All rights reserved.

nvcc is:

nvcc: NVIDIA ® Cuda compiler driver

Copyright © 2005-2006 NVIDIA Corporation

Built on Thu_Nov_29_08:01:13_PST_2007

Cuda compilation tools, release 1.1, V0.2.1221

Any advice would be appreciated.


Figured it out, the MSVC compiler needs to know which subsystem its linking against, (apparently, there is no default) so you need to add
–linker-options “/SUBSYTEM:CONSOLE”
to get rid of the errors.