Mex compiling on 64 bit linux - /usr/bin/ld: cannot find -lstdc++

前端 未结 5 1735
暖寄归人
暖寄归人 2021-01-27 03:01

Okay I am trying to compile a mex file on 64 bit linux, ubuntu to be precise with Matlab 2013a.

First it gave a error that it could not find GLIBCXX_3.4.15

相关标签:
5条回答
  • 2021-01-27 03:41

    Same problem here on Ubuntu 13.04 using MATLAB 2013a. I solved it doing:

    sudo mv /usr/local/MATLAB/R2013a/sys/os/glnxa64/libstdc++.so.6 /usr/local/MATLAB/R2013a/sys/os/glnxa64/libstdc++.so.6.old
    

    To keep a backup just in case.

    And then a symbolic link:

    sudo ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.17 /usr/local/MATLAB/R2013a/sys/os/glnxa64/libstdc++.so.6
    
    0 讨论(0)
  • 2021-01-27 03:48

    Look at this line gcc -O -pthread -shared -Wl,--version-script,/usr/local/MATLAB/R2013a/extern/lib/glnxa64/mexFunction.map -Wl,--no-undefined -o "tload3.mexa64" tload3.o -Wl,-rpath-link,/usr/local/MATLAB/R2013a/bin/glnxa64 -L/usr/local/MATLAB/R2013a/bin/glnxa64 -lmx -lmex -lmat -lm -lstdc++.

    The options with L are the places where gcc/the linker looks for libraries. Id sugest trying to put the symlink in /usr/local/MATLAB/R2013a/bin/glnxa64 ( libstdc++.so.6 is there in 2012a), and start matlab from a terminal, it spits some errors there. Or add the new folder as a CLIB argument.

    And I also would delete the -ansi part for c ( replace it with -std=c99), so that it won't give you errors on using \ style comments in your c code.

    0 讨论(0)
  • 2021-01-27 04:00

    I had the same problem and none of the posted solutions worked for me (i.e. deleting or adding new symlinks), and it turned out that I hadn't installed the appropriate compiler package!

    For me, the solution was:

    sudo yum install gcc-g++
    

    I'm running MATLAB 2014b on 64-bit Linux (RHEL 6).

    0 讨论(0)
  • 2021-01-27 04:02

    You created the link libstdc++.so.6 in /usr/local/MATLAB/R2013a/bin/glnxa64 to the library in your system, installed by apt-get install libstdc++6-4.4-dev .

    Now try creating also a link named libstdc++.so to libstdc++.so.6 in /usr/local/MATLAB/R2013a/bin/glnxa64.

    0 讨论(0)
  • 2021-01-27 04:03

    I had the same problem and this worked for me

    Navigate to the following path cd /usr/local/MATLAB/R2013a/sys/os/glnxa64/, (your path might varies) then remove the libstdc library (or safer rename it)

    sudo mv libstdc++.so.6 libstdc++.so.6.old
    

    I have the same configuration, Ubuntu Linux 64 bit with Matlab 2013a

    0 讨论(0)
提交回复
热议问题