【问题标题】:How to provide Matlab with the old gcc version it wants?如何为 Matlab 提供它想要的旧 gcc 版本?
【发布时间】:2012-01-21 09:26:46
【问题描述】:

在我的电脑上,我有 Ubuntu 10.10 和 gcc 4.4.4。我尝试编译一些使用 CUDA 的 mex 文件,但收到以下错误消息:

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

我假设通过将 Matlab 与 gcc 4.2.3 链接我可以摆脱错误,但我不知道该怎么做。

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

【问题讨论】:

    标签: matlab gcc cuda mex


    【解决方案1】:

    我通过在~/matlab/R2009b/mexopts.sh 中更改我的mexopts.sh file 解决了它(更改为您的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

    【讨论】:

    • 我无法安装 gcc4.2.3。解决此问题后,我会立即尝试您的答案。
    • 发现需要将/Applications/MATLAB_R2013a_Student.app/bin/mexopts.sh复制到~/.matlab/R2013a,需要将CC改成maci64
    猜你喜欢
    • 2019-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-18
    • 1970-01-01
    相关资源
    最近更新 更多