matlab - 在Matlab中使用mex编译C++时,如何摆脱stdafx.h错误?

标签 matlab compiler-errors mex stdafx.h

我正在尝试使用mex编译C++代码,但无法成功编译它。阅读一些相关的博客,我同时安装了Microsoft Visual C++ 2010 Express和Windows软件开发工具包(SDK)7.1,但仍然出现此错误:

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. ************************************************************************

最佳答案

从您的代码中删除#include“stdafx.h”,或创建一个空的stdafx.h。

确保C:\ Users \ JOY \ AppData \ Roaming \ MathWorks \ MATLAB \ R2011a \ mexopts.bat不包含/Yu“stdafx.h”之类的选项

关于matlab - 在Matlab中使用mex编译C++时,如何摆脱stdafx.h错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16183133/

相关文章:

MATLAB - 重新排序数据以显示钟形的智能方法?

android-studio - 任务 ':app:checkDebugAarMetadata' 执行失败

matlab - mex编译错误: expected expression error at Matlab datatype and function

c++ - 如何在我的 MEX 文件中使用 OpenMP 而不会导致 MATLAB 崩溃?

matlab - 跨 block 矩阵乘法 - MATLAB

matlab - 我可以删除占位符变量以节省 Matlab 中的内存吗?

matlab - 尝试将脚本作为函数执行

java - 使用流的 map 收集产生奇怪的编译错误

编译错误说 "node undeclared"第一次在程序中使用,虽然我把 "node"设为全局的

c++ - 对文件使用 fopen 时,matlab 在没有转储文件的情况下崩溃