2011-12-15 67 views
8

在我的電腦上,我安裝了gcc 4.4.4的Ubuntu 10.10。我嘗試編譯它使用CUDA一些MEX文件,我收到以下錯誤信息:通過與GCC 4.2.3我可以擺脫錯誤的鏈接Matlab的如何提供Matlab與舊版gcc版本?

>> 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 

我想,但我不知道如何去做吧。

mex -setup給了我以下選項:

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 

回答

9

我解決它通過改變我的mexopts.sh file,在~/matlab/R2009b/mexopts.sh(與您的MATLAB版本的變化)

找到你的架構(對我來說這glnxa64) ,並像這樣改變它:

 ;; 
    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:你還需要安裝正確版本的gcc

+0

你試過了嗎?它有用嗎? – Oli 2011-12-16 10:50:25