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"不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to enable C++11 in Qt Creator?(如何在 Qt Creator 中启用 C++11?)
How to convert QString to std::string?(如何将 QString 转换为 std::string?)
Qt: can#39;t find -lGL error(Qt:找不到 -lGL 错误)
Serialization with Qt(使用 Qt 进行序列化)
Non-blocking worker - interrupt file copy(非阻塞工作者 - 中断文件复制)
How to link opencv in QtCreator and use Qt library(如何在 QtCreator 中链接 opencv 并使用 Qt 库)