CUDA在Debug下编译有错而Release下无错

错误提示:

1>LIBCMT.lib(invarg.obj) : error LNK2005: __invoke_watson already defined in msvcrtd.lib(MSVCR90D.dll)
1>LIBCMT.lib(tidtable.obj) : error LNK2005: __encode_pointer already defined in msvcrtd.lib(MSVCR90D.dll)
1>LIBCMT.lib(tidtable.obj) : error LNK2005: __decode_pointer already defined in msvcrtd.lib(MSVCR90D.dll)
1>LIBCMT.lib(setlocal.obj) : error LNK2005: __configthreadlocale already defined in msvcrtd.lib(MSVCR90D.dll)
1>LIBCMT.lib(crt0dat.obj) : error LNK2005: __amsg_exit already defined in msvcrtd.lib(MSVCR90D.dll)
1>LIBCMT.lib(crt0dat.obj) : error LNK2005: __initterm_e already defined in msvcrtd.lib(MSVCR90D.dll)
1>LIBCMT.lib(crt0dat.obj) : error LNK2005: _exit already defined in msvcrtd.lib(MSVCR90D.dll)
1>LIBCMT.lib(crt0dat.obj) : error LNK2005: __exit already defined in msvcrtd.lib(MSVCR90D.dll)
1>LIBCMT.lib(crt0dat.obj) : error LNK2005: __cexit already defined in msvcrtd.lib(MSVCR90D.dll)

在经过搜索后采用了忽略 msvcrtd.lib,额外的库添加:LIBCMT.lib

这样可以编译通过,但是Debug版本运行后很多错误提示。

后加入群,两个人的意见有建设性!

1. 改成MTD,但现在编译会提示

1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxver_.h(81) : fatal error C1189: #error :  Please use the /MD switch for _AFXDLL builds
然后他说: 也就是改用静态库,同时MTD。编译运行通过

_AFXDLL tells the compiler to use the DLL version of the MFC libraries. But when you do this you must also use the DLL version of the CRT libraries (/MD compiler option).
 
When you switched to static linking, you should have changed to "Use MFC in a static library" (as Hans told you). This would have automatically changed your CRT setting to /MT. But it seems that you just changed to /MT without changing the MFC setting, so your project was inconsistent. When you got rid of _AFXDLL, the compiler thought you did not want MFC at all, so it did not recognize the MFC calls.
2.

把这两个目录:

SPH-CUDA(736183739) 17:40:36
C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 3.2\C\common
SPH-CUDA(736183739) 17:40:50
C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 3.2\shared
下的重新用MDd编译。默认的是用MT编译的,而我们自己自动生成的MFC里默认是MD编译的,也就是不一致!

但这个我后来再改第一个方法成功后没有尝试这个。

posted on 2011-08-11 18:04  kyleada  阅读(1669)  评论(1编辑  收藏  举报

导航