【发布时间】:2014-05-29 16:22:33
【问题描述】:
我正在尝试在 Matlab 中构建一个包含 m 文件和 c++ (cpp) 源文件的源代码包。
源文件夹有一个简单的Matlab Script来编译一个文件夹中的所有cpp文件:
function compileDir_simple(Cdir)
if nargin<1
Cdir=pwd;
end
files = dir(fullfile(Cdir,'*.cpp'));
oldDir=pwd;
cd(Cdir);
for j=1:length(files)
try
cm = sprintf('mex -largeArrayDims %s',files(j).name);
disp(cm);
eval(cm);
catch
disp(lasterr);
disp('IGNORE if the file is a C++ file which is not a mex file (ie without a mexFunction inside)');
end
end
cd(oldDir);
在内部,它使用“mex -largeArrayDims”。但是,我的问题是,当我评估该语句时,Matlab 尝试通过包含在 MATLAB 本身中的 C 编译器构建所选文件。当我调用 mex -setup 时,我看到:
墨西哥 - 设置 请选择您的编译器来构建外部接口 (MEX) 文件:
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
[0] None
Compiler:
我安装了 Bloodshed C++ 编译器并将其 bin 文件夹 ( 添加到 Windows 环境变量中,但我仍然无法在已安装编译器列表中看到我的 C++ 编译器。只有 Lcc-win32 出现。声明它是合适的我第一次编译 mex 文件的经验。
【问题讨论】:
-
我不想安装 Visual Studio C++(更多下载时间 + 内存需求)并找到一种更简单、更快捷的 C++ 编译方法,而唯一的其他适用于 Windows 的 C++ 编译器是 Dev C++。答案是正确的,它不是 MATLAB 支持的编译器