问题描述
在我的电脑我有Ubuntu 10.10与gcc 4.4.4。我尝试编译一些使用CUDA的mex文件,并得到以下错误信息:
> cns_build('hmax')
compiling ...
/home/leMe/hmax/cns/source/common_dec.h(54):warning:省略异常规范与以前的函数operator new (size_t)
/usr/include/c++/4.4/new(91):here
/home/leMe/hmax/cns/source/common_dec.h(55):warning:省略异常规范与以前的函数operator new [](size_t)不兼容
/usr/include/c++/4.4/new(92):here
/ home / leMe / hmax / cns / source / common_dec .h(56):warning:省略异常规范与以前的函数operator delete(void *)不兼容
/usr/include/c++/4.4/new(93):here
/ home /leMe/hmax/cns/source/common_dec.h(57):warning:省略异常规范与以前的函数operator delete [](void *)不兼容
/usr/include/c++/4.4/ new(94):here
分段错误
CUDA预处理[nvcc]失败
警告:您使用的是gcc版本4.4.4-14ubuntu5)。 MEX当前支持的版本
为4.2.3。
有关当前支持的编译器的列表,请参阅:
http://www.mathworks.com/support/compilers/current_release/
CPU编译成功
我假设通过链接Matlab和gcc 4.2.3我可以摆脱错误,但我不知道如何做
mex -setup
提供以下选项: p>
1:/home/leMe/Matlab/bin/gccopts.sh:
用于构建gcc MEX文件的模板选项文件
2:/home/leMe/Matlab/bin/mexopts.sh:
用于通过系统构建MEX文件的模板选项文件ANSI编译器
解决方案我通过更改我的
mexopts.sh文件解决了
,〜/ matlab / R2009b / mexopts.sh
(更改为您的matlab版本)
架构(对我来说是
glnxa64
),并改变它像这样:;;
glnxa64)#< -----------------------找到这个
RPATH = - wl,-rpath-link,$ TMW_ROOT / bin / $ Arch
#StorageVersion:1.0
#CkeyName:GNU C
#CkeyManufacturer:GNU
#CkeyLanguage:C
#CkeyVersion:
CC ='gcc-4.1'#< ---------------------------------- CHANGE HERE
CFLAGS =' - ansi -D_GNU_SOURCE'
CFLAGS =$ CFLAGS -fexceptions
CFLAGS =$ CFLAGS -fPIC -fno-omit-frame-pointer -pthread
CLIBS = $ RPATH $ MLIBS -lm
COPTIMFLAGS =' - O -DNDEBUG'
CDEBUGFLAGS =' - g'
CLIBS =$ CLIBS -lstdc ++
#
#C ++ keyName:GNU C ++
#C ++ keyManufacturer:GNU
#C ++ keyLanguage:C ++
#C ++ keyVersion:
CXX ='g ++ - 4.1 '#< ---------------------------------- CHANGE HERE
CXXFLAGS =' - ansi - D_GNU_SOURCE'
CXXFLAGS =$ CXXFLAGS -fPIC -fno-omit-frame-pointer -pthread
CXXLIBS =$ RPATH $ MLIBS -lm
CXXOPTIMFLAGS =' - O -DNDEBUG'
CXXDEBUGFLAGS =' - g'
PS:您还需要安装正确的版本gccOn my computer I have Ubuntu 10.10 with gcc 4.4.4. I try to compile some mex files which use CUDA and I get following error message:
>> cns_build('hmax') compiling... /home/leMe/hmax/cns/source/common_dec.h(54): warning: omission of exception specification is incompatible with previous function "operator new(size_t)" /usr/include/c++/4.4/new(91): here /home/leMe/hmax/cns/source/common_dec.h(55): warning: omission of exception specification is incompatible with previous function "operator new[](size_t)" /usr/include/c++/4.4/new(92): here /home/leMe/hmax/cns/source/common_dec.h(56): warning: omission of exception specification is incompatible with previous function "operator delete(void *)" /usr/include/c++/4.4/new(93): here /home/leMe/hmax/cns/source/common_dec.h(57): warning: omission of exception specification is incompatible with previous function "operator delete[](void *)" /usr/include/c++/4.4/new(94): here Segmentation fault CUDA preprocessing [nvcc] failed Warning: You are using gcc version "4.4.4-14ubuntu5)". The version currently supported with MEX is "4.2.3". For a list of currently supported compilers see: http://www.mathworks.com/support/compilers/current_release/ CPU compilation successful
I assume by linking Matlab with gcc 4.2.3 I can get rid of the error, but I don't know how to do it.
mex -setup
gives me following options:1: /home/leMe/Matlab/bin/gccopts.sh : Template Options file for building gcc MEX-files 2: /home/leMe/Matlab/bin/mexopts.sh : Template Options file for building MEX-files via the system ANSI compiler
解决方案I solved it by changing my
mexopts.sh file
, in~/matlab/R2009b/mexopts.sh
(change with your matlab version)Find your architecture (for me it's
glnxa64
), and change it like this:;; glnxa64) #<----------------------- FIND THIS RPATH="-Wl,-rpath-link,$TMW_ROOT/bin/$Arch" # StorageVersion: 1.0 # CkeyName: GNU C # CkeyManufacturer: GNU # CkeyLanguage: C # CkeyVersion: CC='gcc-4.1' #<---------------------------------- CHANGE HERE CFLAGS='-ansi -D_GNU_SOURCE' CFLAGS="$CFLAGS -fexceptions" CFLAGS="$CFLAGS -fPIC -fno-omit-frame-pointer -pthread" CLIBS="$RPATH $MLIBS -lm" COPTIMFLAGS='-O -DNDEBUG' CDEBUGFLAGS='-g' CLIBS="$CLIBS -lstdc++" # # C++keyName: GNU C++ # C++keyManufacturer: GNU # C++keyLanguage: C++ # C++keyVersion: CXX='g++-4.1' #<---------------------------------- CHANGE HERE CXXFLAGS='-ansi -D_GNU_SOURCE' CXXFLAGS="$CXXFLAGS -fPIC -fno-omit-frame-pointer -pthread" CXXLIBS="$RPATH $MLIBS -lm" CXXOPTIMFLAGS='-O -DNDEBUG' CXXDEBUGFLAGS='-g'
PS: you also need to install the right version of gcc
这篇关于如何提供Matlab与它想要的旧gcc版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!