您的位置:首页 > 编程语言 > MATLAB

Matlab R2013a: C++ MEX on Ubuntu 14.04 64-bit

2015-02-01 19:16 549 查看
原文地址:
http://blogs.bu.edu/mhirsch/2013/07/matlab-r2013a-mex-on-ubuntu-13-04-64-bit/
Note: the way Mex setup works has changed in R2014a and newer. This is for older version of Matlab R2013 and older

Ubuntu 14.04 comes with GCC 4.8, but Matlab R2013a gives warnings about needing GCC 4.4 if using MEX features.
(1) Packages to install (synaptic or apt-get)
[code]
gcc-4.4
g++-4.4

(2) in Matlab, type
mex -setup
and press 1 to copy the mexopts.sh to your ~/.matlab/R2013a/mexopts.sh
(3)
sudo chmod 644 ~/.matlab/R2013a/mexopts.sh

(allows you to edit this file)
(3)
gedit mexopts.sh

and change:
CC='gcc-4.4'
CXX='g++-4.4'

Also to save yourself grief when you’re using a modern C++ syntax file (especially if you get errors like
error: expected expression before ‘/’ token
)
then make this additional changes:
#CFLAGS='-ansi -D_GNU_SOURCE'
CFLAGS='-std=c99 -D_GNU_SOURCE'

(4) Save/exit gedit and restart Matlab. You should now be able to use MEX in Matlab R2013a under Ubuntu 14.04.

[/code]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: