Error when compiling c++11 code in a Matlab mex file

孤街浪徒 提交于 2019-12-01 08:11:33
Wok

Thanks to Praetorian's comment, I could pinpoint the problem. I had edited the wrong lines in mexopts.sh. Indeed, the CXXFLAGS appears at 3 different places, I had edited the flags at the first place, but it was necessary and sufficient to edit it at the second place (the first place was a decoy).

See for instance:

$ grep -n CXXLIBS /user/wok/home/.matlab/R2012b/mexopts.sh
74:             CXXLIBS="$RPATH $MLIBS -lm"
129:            CXXLIBS="$RPATH $MLIBS -lm"
199:            CXXLIBS="$MLIBS -lstdc++"

So I edited the lines around line 129. The following lines

        CXX='g++'
        CXXFLAGS='-ansi -D_GNU_SOURCE'
        CXXFLAGS="$CXXFLAGS -fPIC -fno-omit-frame-pointer -pthread"
        CXXLIBS="$RPATH $MLIBS -lm"
        CXXOPTIMFLAGS='-O -DNDEBUG'
        CXXDEBUGFLAGS='-g'

become

        CXX='g++'
        CXXFLAGS='-std=c++11 -fopenmp -march=native -D_GNU_SOURCE'
        CXXFLAGS="$CXXFLAGS -fPIC -fno-omit-frame-pointer -pthread"
        CXXLIBS="$RPATH $MLIBS -lm -lgomp"
        CXXOPTIMFLAGS='-Ofast -DNDEBUG'
        CXXDEBUGFLAGS='-g'
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!