問題描述
我正在將 Matlab
、C
和 Cuda
集成到一個(gè)項(xiàng)目中.我使用Matlab mix為了將用c編寫的matlab mx函數(shù)與cuda運(yùn)行時(shí)庫連接起來,出現(xiàn)關(guān)于c文件和庫之間靜態(tài)發(fā)布和動(dòng)態(tài)發(fā)布沖突的鏈接錯(cuò)誤.任何人都可以解決這個(gè)問題嗎?
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.
推薦答案
當(dāng)您靜態(tài)將項(xiàng)目與庫(通常是具有 .lib 擴(kuò)展名的文件)鏈接但鏈接器使用鏈接器時(shí),可能會(huì)發(fā)生此錯(cuò)誤Visual Studio 項(xiàng)目中的設(shè)置設(shè)置為動(dòng)態(tài)鏈接(意味著鏈接將在運(yùn)行時(shí)發(fā)生,通常使用 .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).
要定義您需要項(xiàng)目使用靜態(tài)鏈接,請(qǐng)啟動(dòng) Visual Studio.在解決方案資源管理器窗格中,右鍵單擊項(xiàng)目名稱,然后選擇屬性.展開如下圖所示的屬性:C/C++ --> Code Generation --> Runtime Library,從里面選擇Multi-threaded (/MT)
選項(xiàng)下拉式菜單.
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.
這篇關(guān)于LNK2038:檢測(cè)到“RuntimeLibrary"不匹配:值“MT_StaticRelease"與 file.obj 中的值“MD_DynamicRelease"不匹配的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!