2013-04-24 54 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中”