2011-12-15 28 views
8

Trên máy tính của tôi, tôi có Ubuntu 10.10 với gcc 4.4.4. Tôi cố gắng để biên dịch một số tác phẩm mex mà sử dụng CUDA và tôi nhận được thông báo lỗi sau:Làm thế nào để cung cấp Matlab với phiên bản gcc cũ mà nó muốn?

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

tôi giả bằng cách liên kết với Matlab gcc 4.2.3 tôi có thể thoát khỏi những sai sót, nhưng tôi không biết làm thế nào để làm điều đó.

mex -setup mang lại cho tôi tùy chọn sau:

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 

Trả lời

9

Tôi giải quyết nó bằng cách thay đổi mexopts.sh file của tôi, trong ~/matlab/R2009b/mexopts.sh (thay đổi với phiên bản matlab của bạn)

Tìm kiến ​​trúc của bạn (đối với tôi nó là glnxa64) và thay đổi nó như sau:

 ;; 
    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: bạn cũng cần cài đặt đúng phiên bản gcc

+0

Bạn đã thử chưa? Nó có hoạt động không? – Oli

+0

Tôi sẽ thử ngay hôm nay! – Framester

+0

Tôi không cài đặt gcc4.2.3. Tôi thử câu trả lời của bạn ngay sau khi tôi sửa lỗi này. – Framester

Các vấn đề liên quan