LNK2038:检测到“RuntimeLibrary"不匹配:值“MT_StaticRelease"

LNK2038: mismatch detected for #39;RuntimeLibrary#39;: value #39;MT_StaticRelease#39; doesn#39;t match value #39;MD_DynamicRelease#39; in file.obj(LNK2038:检测到“RuntimeLibrary不匹配:值“MT_StaticRelease与 file.obj 中的值“MD_DynamicReleas
本文介绍了LNK2038:检测到“RuntimeLibrary"不匹配:值“MT_StaticRelease"与 file.obj 中的值“MD_DynamicRelease"不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在将 MatlabCCuda 集成到一个项目中.我使用Matlab mix为了将用c编写的matlab mx函数与cuda运行时库连接起来,出现关于c文件和库之间静态发布和动态发布冲突的链接错误.任何人都可以解决这个问题吗?

I am Integrating Matlab, C and Cuda together in a project. I used Matlab mix in order to connect matlab mx function written in c with the cuda runtime library, a linking error appear about conflict in static release and dynamic release between the c file and the library. Can anyone solve this?

error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in file.obj. 

推荐答案

当您静态将项目与库(通常是具有 .lib 扩展名的文件)链接但链接器使用链接器时,可能会发生此错误Visual Studio 项目中的设置设置为动态链接(意味着链接将在运行时发生,通常使用 .dll 文件).

This error can occur when you are statically linking your project with a library (typically a file with .lib extension) but the linker setting in your Visual Studio project are set to dynamically link (meaning the link will occur during runtime, usually with a .dll file).

要定义您需要项目使用静态链接,请启动 Visual Studio.在解决方案资源管理器窗格中,右键单击项目名称,然后选择属性.展开如下图所示的属性:C/C++ --> Code Generation --> Runtime Library,从里面选择Multi-threaded (/MT)选项下拉式菜单.

To define that you need the project to use static linking start Visual Studio. In the Solution Explorer pane, right click the project name, and select Properties. Expand the properties as shown in the figure below: C/C++ --> Code Generation --> Runtime Library, select the Multi-threaded (/MT) option from the dropdown menu.

这篇关于LNK2038:检测到“RuntimeLibrary"不匹配:值“MT_StaticRelease"与 file.obj 中的值“MD_DynamicRelease"不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Unable to access non-const member functions of objects in C++ std::set(无法访问 C++ std::set 中对象的非常量成员函数)
Constructing std::function argument from lambda(从 lambda 构造 std::function 参数)
STL BigInt class implementation(STL BigInt 类实现)
Sync is unreliable using std::atomic and std::condition_variable(使用 std::atomic 和 std::condition_variable 同步不可靠)
Move list element to the end in STL(在 STL 中将列表元素移动到末尾)
Why is overloading operatoramp;() prohibited for classes stored in STL containers?(为什么禁止对存储在 STL 容器中的类重载 operatoramp;()?)