简体   繁体   English

CUDA:错误LNK2005:MSVCRT.lib中已经定义了DllMain

[英]CUDA: error LNK2005: DllMain already defined in MSVCRT.lib

When the cuda_test.cu file is not included in the project, the code runs fine. 如果项目中未包含cuda_test.cu文件,则代码可以正常运行。

When such a file is included, I receive the following error message 当包含这样的文件时,我会收到以下错误消息

mfcs100u.lib(dllmodul.obj) : error LNK2005: DllMain already defined in MSVCRT.lib(dllmain.obj)

cuda_test.c u has the following header files, a global function and a wrapper. cuda_test.c具有以下头文件,全局函数和包装器。

#include <cuda.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>

So I am not sure what causes this problem. 所以我不确定是什么原因导致了这个问题。

After some research, it seems this problem is fairly common and has fixes . 经过一些研究,看来这个问题相当普遍并且已经解决 But this starts giving trouble in a different part of the code. 但这开始在代码的不同部分带来麻烦。 ("StdAfx.h" is included in all .cpp files, if this information is relevant). (如果此信息相关,则所有.cpp文件中都包含“ StdAfx.h”)。

It is a huge project written in C++ and I am trying to parallelize some parts of it. 这是一个用C ++编写的庞大项目,我正在尝试并行化其中的某些部分。

Some help will be hugely appreciated. 一些帮助将不胜感激。 I can give extra details if needed. 如果需要,我可以提供其他详细信息。

You need to make sure that all parts of your app link against the same runtime. 您需要确保应用程序的所有部分都链接到同一运行时。

In Solution Explorer, right click your .cu file and select Properties. 在解决方案资源管理器中,右键单击您的.cu文件,然后选择“属性”。 Go to CUDA C/C++ > Host and make sure that Runtime Library is set to the same as for the rest of your project. 转到CUDA C/C++ > Host ,并确保将Runtime Library设置为与项目其余部分相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM