我需要每天编译 simulink 代码并生成 dll。为此,我使用 Linux 版本的 MATLAB 开发所有内容。之后,我启动 VirtualBox 并编译 simulink 块并生成 dll。由于内存使用量大,我想知道是否有其他不需要那么多内存的解决方案。
答案1
最后我找到了答案,交叉编译器解决了这个问题,如果出现错误,我会编辑makefile并重新编译它。
try
rtwbuild(modelName);
catch
% If it is linux try to compile using cross compiler
% This required the cross compile to be installed
disp('Compilation faild');
if strcmp(computer, 'GLNXA64')
disp('Trying to compile for linux using cross-compiler')
cd([modelName '_ert_shrlib_rtw'])
C_FILE = 'wesys_control.mk';
fid = fopen(C_FILE,'r');
f=fread(fid,'*char')';
fclose(fid);
% Replacing the stop time
f = strrep(f,'CC = gcc','CC = i686-w64-mingw32-gcc');
f = strrep(f,'LD = gcc','LD = i686-w64-mingw32-gcc');
f = strrep(f,'CPP = g++','CPP = i686-w64-mingw32-g++');
f = strrep(f,'CPP_LD = g++','CPP_LD = i686-w64-mingw32-g++');
f = strrep(f,'AR = ar','AR = i686-w64-mingw32-ar');
fid = fopen(C_FILE,'w');
fprintf(fid,'%s',f);
fclose(fid);
!make -f wesys_control.mk all
cd ('..')
end
end