Use of CUDA in a DLL Lot of linker Error when linking

(Warnig: NewBee)

I have create a test project (with MFC, MT) and all works fine. Now I want to include this code into a AFXEXT-Dll, but get a lot of linker error. Linker not Compiler Errors:

LIBCMT.lib(unhandld.obj) : warning LNK4078: multiple ‘.CRT’ sections found with different attributes (40300040)
LIBCMT.lib(loctim64.obj) : warning LNK4006: __localtime64 already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
LIBCMT.lib(gmtime.obj) : warning LNK4006: _gmtime already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
LIBCMT.lib(getenv.obj) : warning LNK4006: _getenv already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
LIBCMT.lib(crt0dat.obj) : warning LNK4006: _exit already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
LIBCMT.lib(_strftime.obj) : warning LNK4006: _strftime already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
LIBCMT.lib(crt0init.obj) : warning LNK4006: ___xi_a already defined in msvcrtd.lib(cinitexe.obj); second definition ignored
LIBCMT.lib(crt0init.obj) : warning LNK4006: ___xi_z already defined in msvcrtd.lib(cinitexe.obj); second definition ignored
LIBCMT.lib(crt0init.obj) : warning LNK4006: ___xc_a already defined in msvcrtd.lib(cinitexe.obj); second definition ignored
LIBCMT.lib(crt0init.obj) : warning LNK4006: ___xc_z already defined in msvcrtd.lib(cinitexe.obj); second definition ignored
LIBCMT.lib(hooks.obj) : warning LNK4006: “void __cdecl terminate(void)” (?terminate@@YAXXZ) already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
LIBCMT.lib(realloc.obj) : warning LNK4006: _realloc already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
LIBCMT.lib(unhandld.obj) : warning LNK4078: multiple ‘.CRT’ sections found with different attributes (40300040)
LIBCMT.lib(loctim64.obj) : warning LNK4006: __localtime64 already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
LIBCMT.lib(gmtime.obj) : warning LNK4006: _gmtime already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
LIBCMT.lib(getenv.obj) : warning LNK4006: _getenv already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
LIBCMT.lib(crt0dat.obj) : warning LNK4006: _exit already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
LIBCMT.lib(_strftime.obj) : warning LNK4006: _strftime already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
LIBCMT.lib(crt0init.obj) : warning LNK4006: ___xi_a already defined in msvcrtd.lib(cinitexe.obj); second definition ignored
LIBCMT.lib(crt0init.obj) : warning LNK4006: ___xi_z already defined in msvcrtd.lib(cinitexe.obj); second definition ignored
LIBCMT.lib(crt0init.obj) : warning LNK4006: ___xc_a already defined in msvcrtd.lib(cinitexe.obj); second definition ignored
LIBCMT.lib(crt0init.obj) : warning LNK4006: ___xc_z already defined in msvcrtd.lib(cinitexe.obj); second definition ignored
LIBCMT.lib(hooks.obj) : warning LNK4006: “void __cdecl terminate(void)” (?terminate@@YAXXZ) already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
LIBCMT.lib(realloc.obj) : warning LNK4006: _realloc already defined in msvcrtd.lib(MSVCR71D.dll); second definition ignored
Creating library .\Debug_C7/PicFunc.lib and object .\Debug_C7/PicFunc.exp
LINK : warning LNK4098: defaultlib ‘msvcrtd.lib’ conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib ‘LIBCMT’ conflicts with use of other libs; use /NODEFAULTLIB:library
LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function __mainCRTStartup
LINK : warning LNK4078: multiple ‘.rdata’ sections found with different attributes (C0000040)
<<<<<<<<<<<<<<<<<<<<
What have I done wrong???
Please any hints

TIA
Willi

Seems that you are linking against two different versions of the C Runtime library. Check that all libraries link against the same (e.g. against Multithreaded (Debug) DLL).

best, Hannes

I noticed that the CUDA build rule does not automatically switch linkage of the multithreading runtime libs from release /MT to debug /MTd for the Debug compile targets. However, the MSVS C++ build targets do that, hence a conflict is generated. To avoid it, right-click on your project, select properties, go to the cuda build rule (I use CUDA build rule v3.0.0) / Hybrid CUDA/C++ options and set the runtime library to Multi-Threaded Debug (/MTd) for your debug and EmuDebug configurations.