2013-10-23 47 views
3

我有一個爲MATLAB編寫的自定義DLL,它在我們的開發機器上工作正常。然而,當我嘗試一個乾淨的機器,沒有開發工具上,我得到的消息:MATLAB的自定義C DLL - 加載庫錯誤

>> loadlibrary CMatLab CMatLab.h 
??? Error using ==> loadlibrary at 279 
Microsoft Visual C++ 2005 or 2008 is required to use this feature. 

一些研究,它似乎很清楚,一個編譯器必須解析運行時的頭文件之後,所以我安裝了標準的Windows SDK,運行mex -setup來選擇編譯器,但我仍然得到相同的錯誤信息。這是我爲選擇編譯器所做的。

>> mex -setup 
Please choose your compiler for building external interface (MEX) files: 

Would you like mex to locate installed compilers [y]/n? mex -setup 

Select a compiler: 
[1] Microsoft Visual C++ 2008 SP1 in C:\Program Files (x86)\Microsoft Visual Studio 9.0 

[0] None 

Compiler: 1 

Please verify your choices: 

Compiler: Microsoft Visual C++ 2008 SP1 
Location: C:\Program Files (x86)\Microsoft Visual Studio 9.0 

Are these correct [y]/n? y 

*************************************************************************** 
    Warning: MEX-files generated using Microsoft Visual C++ 2008 require 
      that Microsoft Visual Studio 2008 run-time libraries be 
      available on the computer they are run on. 
      If you plan to redistribute your MEX-files to other MATLAB 
      users, be sure that they have the run-time libraries. 
*************************************************************************** 

Trying to update options file: C:\Users\adriane\AppData\Roaming\MathWorks\MATLAB\R2010b\mexopts.bat 
From template:    D:\Matlab\bin\win64\mexopts\msvc90opts.bat 

Done . . . 

我真的不希望這臺機器上安裝Visual Studio,因爲它降低了它的實用性,作爲釋放測試平臺建立我們其他的工具和軟件。任何想法的人?我發現其他人也有同樣的問題,但我沒有看到明確的解決方案。操作系統是Windows 7專業版64位。該DLL是用VS2008構建的。

+0

爲什麼要投票? – ExpatEgghead

+0

不是一個明顯的解決方案。好的問題和答案。開發機器測試機器的過程很好理解。 – chappjc

回答

3

嘗試使用'MFILENAME'選項來生成loadlibrary以生成一個「protofile」,以便將來可以通過@PROTOFILE語法加載DLL。在您的開發機器上生成文件,並將其帶入測試機器。

因此,在開發計算機上:

loadlibrary('CMatLab', 'CMatLab.h', 'mfilename', 'cmatlab_proto'); 

一起到測試機的DLL帶,文件標記爲 '咚',和cmatlab_proto.m。在測試機上運行:

loadlibrary('CMatLab', @cmatlab_proto) 
+0

謝謝彼得。這解決了它。我必須翻閱關於此的MatLab文檔,否則我永遠也找不到答案。算法組突然開始微笑。 – ExpatEgghead

+1

+1。謝謝(你的)信息。問:您能否提供更詳細的說明或相關文檔?另外,我對測試機器上運行的命令感到困惑。你不是說_test_機器應該用第一個命令生成的「protofile」運行第二個命令嗎?感謝澄清。 – chappjc

+0

是的,很好的錯字,固定。我發現的唯一文檔是在'doc loadlibrary'中。它看起來像編譯器用於解析頭文件,並在必要時生成thunk接口。從可選的protofile接口的描述中,我推斷編譯器將不會在隨後的加載中需要,然後進行驗證。 – Peter