matlab编译C++文件,依赖库函数的编译方法

类似gcc中的编译过程,可以通过写make.m文件来进行编译:
make.m的写法(在原博主文档中进行了简化):

clear all;
is_64bit = strcmp(computer,'MACI64') || strcmp(computer,'GLNXA64') || strcmp(computer,'PCWIN64');
CPPFLAGS = ' -IE:\opencv\opencv\build\include -IE:\opencv\opencv\build\include\opencv'; % 包含目录,主要-I和路径之间没有空格
LDFLAGS = ' -LE:\opencv\opencv\build\x64\vc14\lib';	%库目录 -L和路径间没有空格 
LIBS = ' -lopencv_world310 -lopencv_world310d ';
if is_64bit
	CPPFLAGS = [CPPFLAGS ' -largeArrayDims'];%如果是64位则加上,用于提高性能
end
compile_files = { 
	% the list of your code files which need to be compiled
	'RGB2Gray.cpp'%编译的cpp,可以是多个
};
 
 
%-------------------------------------------------------------------
%% compiling...
for k = 1 : length(compile_files)
    str = compile_files{k};
    fprintf('compilation of: %s\n', str);
    str = [str  CPPFLAGS LDFLAGS LIBS]%拼接成命令
    args = regexp(str, '\s+', 'split');%这个必须得加上,按空格分割
    mex(args{:});%编译
end
 
fprintf('Congratulations, compilation successful!!!\n');

原文档路径:https://blog.csdn.net/zouxy09/article/details/20553007

regexp(str, ‘\s+’, ‘split’);方法的说明路径:https://blog.csdn.net/gotomic/article/details/7898307

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值