ubuntu下利用MATLAB将c/cpp文件转化成mexa64文件

我的是ubuntu14.04系统,matlab2015b

ubuntu下将cpp转化成mexa64文件,不知为何,文件并没有出现,但是转化之后matlab已经有这个内置函数了,下面直接出方法

这篇参考博客讲的是windows下的http://blog.csdn.net/tiandijun/article/details/50549802

下面方法是linux下的

比如我们的cpp文件是helloword.cpp

首先在matlab的命令窗口输入

mex -setup然后会出现一系列提示,ubuntu的如下:

MEX configured to use 'gcc' for C language compilation.
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/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.

To choose a different language, select one from the following:
 mex -setup C++
 mex -setup FORTRAN

点击 mex -setup C++使用g++来编译

然后会提示

MEX configured to use 'g++' for C++ language compilation.
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/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.


然后直接在命令窗口输入

mex 路径/helloword.cpp就行,注意是绝对路径

不报错就编译成功了,这时候就可以在matlab里输入 helloword了,不知道为啥我并没有出现mexa64文件,不过helloword这个函数以及被安置到matlab内置函数中了,

这篇博客提到了一个小例子,可以参考

http://blog.csdn.net/jkhere/article/details/8906274

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值