2013-04-24 87 views
2

我想用mex編譯C++代碼,但無法成功編譯它。閱讀一些相關的博客,我安裝了微軟的Visual C++ 2010 Express和Windows軟件開發工具包(SDK)7.1,但仍然它給這個錯誤:在matlab中使用mex編譯C++時,如何擺脫stdafx.h錯誤?

facePart.cpp(5) : fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory

任何人都可以幫我找出問題,請...?

我使用的是64位Windows平臺,matlab版2011A ...

順便說一句,打字MEX -setup後,它給了我這樣的事情:

Please choose your compiler for building MEX-files: 

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

Select a compiler: [1] Microsoft Visual C++ 2010 Express in C:\Program Files (x86)\Microsoft Visual Studio 10.0 

[0] None 

Compiler: 1 

Please verify your choices: 

Compiler: Microsoft Visual C++ 2010 Express Location: C:\Program Files (x86)\Microsoft Visual Studio 10.0 

Are these correct [y]/n? y 

************************************************************************* Warning: MEX-files generated using Microsoft Visual C++ 2010 require that Microsoft Visual Studio 2010 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\JOY\AppData\Roaming\MathWorks\MATLAB\R2011a\mexopts.bat From template: C:\PROGRA~1\MATLAB\R2011a\bin\win64\mexopts\msvc100freeopts.bat 

Done . . . 

************************************************************************ Warning: The MATLAB C and Fortran API has changed to support MATLAB variables with more than 2^32-1 elements. In the near future you will be required to update your code to utilize the new API. You can find more information about this at: http://www.mathworks.com/support/solutions/en/data/1-5C27B9/?solution=1-5C27B9 Building with the -largeArrayDims option enables the new API. ************************************************************************ 
+0

沒有你的代碼具有的#include「stdafx選項.h「在裏面? – Bull 2013-04-24 04:37:45

+0

嗨Anthon,是的,它有 – Joy 2013-04-24 05:54:28

+1

你不需要它。請參閱以下相關問題:[Visual Studio中「stdafx.h」的用法是什麼?](http://stackoverflow.com/questions/4726155/whats-the-use-for-stdafx-h-in-visual-工作室) – 2013-04-24 06:42:40

回答

1

刪除#在你的代碼中包含「stdafx.h」,或者創建一個空的stdafx.h。

確保C:\用戶\ JOY \應用程序數據\漫遊\ MathWorks公司\ MATLAB \ R2011a \ mexopts.bat不包含像/於 「stdafx.h中」