【MATLAB】matlabR2010a與vs2010聯合編譯設置


在matlab中編譯C++程序,首先要配置編譯器
>> mex -setup
Please choose your compiler for building external interface (MEX) files: 

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

Select a compiler: 
[1] Lcc-win32 C 2.4.1 in D:\MATLAB\R2010a\sys\lcc 
[2] Microsoft Visual C++ 2010 in D:\Microsoft Visual Studio 10.0 

[0] None
選擇2

若沒有2的選項,解決方案如下:
網上下載VS2010support文件包【VS2010MEXSupport.rar】
解壓,放入相應matlab安裝目錄中。(例如:D:\MATLAB\R2010a\win32\mexopts)

再次運行上述代碼后就會顯示[2]了。

另外還有一個常見問題:
VS2010中的yvals.h與Matlab的matrix.h同時包含對char16_t的定義,當同時包含這兩個頭文件,
會導致重復定義char16_t的錯誤:
D:\Microsoft Visual Studio 10.0\VC\INCLUDE\yvals.h
(576) : error C2371: 'char16_t' : redefinition; 
different basic types
D:\Matlab\r2010a\extern\include\matrix.h(330) : see 
declaration of 'char16_t'

最簡解決方案:在包含matrix.h之前包含yvals.h
例如:

#include <yvals.h>
#if (_MSC_VER >= 1600)
#define __STDC_UTF_16__
#endif

……
#include "mex.h"


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM