2

I'm trying to build a C program on Matlab 2012a, through the command:

mex mat_trans2.c

And I'm getting this error:

/usr/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status

    mex: link of ' "mat_trans2.mexa64"' failed.

Error using mex (line 206)
Unable to complete successfully.

Some time ago I was able to build .c files, I don't know what is happening now! Maybe something has changed after a system upgrade on my Kubuntu 12.04 64 bit.

Is there someone who know how to solve this?

Thank you!!!!

Edit: I edit the message to reply at Shai. Running:

mex -v mat_trans2.c

I get:

**************************************************************************
  Warning: Neither -compatibleArrayDims nor -largeArrayDims is selected. 
           Using -compatibleArrayDims. In the future, MATLAB will require
           the use of -largeArrayDims and remove the -compatibleArrayDims
           option. For more information, see:
           http://www.mathworks.com/help/techdoc/matlab_external/bsflnue-1.html
**************************************************************************

/home/mafalda/MATLAB/bin/mex: 1: /home/mafalda/MATLAB/bin/util/oscheck.sh: /lib64/libc.so.6: not found
/home/mafalda/MATLAB/bin/mex: 1: /home/mafalda/MATLAB/bin/util/oscheck.sh: /lib64/libc.so.6: not found
-> mexopts.sh sourced from directory (DIR = $PREF_DIR)
   FILE = /home/mafalda/.matlab/R2012a/mexopts.sh
----------------------------------------------------------------
->    MATLAB                = /home/mafalda/MATLAB
->    CC                    = gcc-4.4
->    CC flags:
         CFLAGS             = -ansi -D_GNU_SOURCE  -fexceptions -fPIC -fno-omit-frame-pointer -pthread
         CDEBUGFLAGS        = -g
         COPTIMFLAGS        = -O -DNDEBUG
         CLIBS              = -Wl,-rpath-link,/home/mafalda/MATLAB/bin/glnxa64 -L/home/mafalda/MATLAB/bin/glnxa64 -lmx -lmex -lmat -lm -lstdc++
         arguments          =  -DMX_COMPAT_32
->    CXX                   = g++-4.4
->    CXX flags:
         CXXFLAGS           = -ansi -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread
         CXXDEBUGFLAGS      = -g
         CXXOPTIMFLAGS      = -O -DNDEBUG
         CXXLIBS            = -Wl,-rpath-link,/home/mafalda/MATLAB/bin/glnxa64 -L/home/mafalda/MATLAB/bin/glnxa64 -lmx -lmex -lmat -lm
         arguments          =  -DMX_COMPAT_32
->    FC                    = gfortran-4.4
->    FC flags:
         FFLAGS             = -fexceptions -fbackslash -fPIC -fno-omit-frame-pointer
         FDEBUGFLAGS        = -g
         FOPTIMFLAGS        = -O
         FLIBS              = -Wl,-rpath-link,/home/mafalda/MATLAB/bin/glnxa64 -L/home/mafalda/MATLAB/bin/glnxa64 -lmx -lmex -lmat -lm
         arguments          =  -DMX_COMPAT_32
->    LD                    = gcc-4.4
->    Link flags:
         LDFLAGS            = -pthread -shared -Wl,--version-script,/home/mafalda/MATLAB/extern/lib/glnxa64/mexFunction.map -Wl,--no-undefined
         LDDEBUGFLAGS       = -g
         LDOPTIMFLAGS       = -O
         LDEXTENSION        = .mexa64
         arguments          = 
->    LDCXX                 = 
->    Link flags:
         LDCXXFLAGS         = 
         LDCXXDEBUGFLAGS    = 
         LDCXXOPTIMFLAGS    = 
         LDCXXEXTENSION     = 
         arguments          = 
----------------------------------------------------------------

-> gcc-4.4 -c  -I/home/mafalda/MATLAB/extern/include -I/home/mafalda/MATLAB/simulink/include -DMATLAB_MEX_FILE -ansi -D_GNU_SOURCE  -fexceptions -fPIC -fno-omit-frame-pointer -pthread  -DMX_COMPAT_32 -O -DNDEBUG  "mat_trans2.c"

-> gcc-4.4 -O -pthread -shared -Wl,--version-script,/home/mafalda/MATLAB/extern/lib/glnxa64/mexFunction.map -Wl,--no-undefined -o  "mat_trans2.mexa64"  mat_trans2.o  -Wl,-rpath-link,/home/mafalda/MATLAB/bin/glnxa64 -L/home/mafalda/MATLAB/bin/glnxa64 -lmx -lmex -lmat -lm -lstdc++

/usr/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status

    mex: link of ' "mat_trans2.mexa64"' failed.

Error using mex (line 206)
Unable to complete successfully.

I would say the problem is that /lib64/libc.so.6: cannot be found

Plus:

locate libstdc++.so.6
/home/mafalda/MATLAB/bin/glnxa64/libstdc++.so.6
/home/mafalda/MATLAB/bin/glnxa64/libstdc++.so.6.0.13
/home/mafalda/MATLAB/sys/os/glnxa64/libstdc++.so.6
/home/mafalda/MATLAB/sys/os/glnxa64/libstdc++.so.6.0.16
/home/mafalda/MATLAB/toolbox/edalink/foundation/hdllink/scripts/linux32/libstdc++.so.6
/home/mafalda/MATLAB/toolbox/edalink/foundation/hdllink/scripts/linux32/libstdc++.so.6.0.13
/home/mafalda/MATLAB/toolbox/sldv/sldv/polyspace-dvo/lib/x86-linux/libstdc++.so.6
/usr/lib/i386-linux-gnu/libstdc++.so.6
/usr/lib/i386-linux-gnu/libstdc++.so.6.0.16
/usr/lib/x86_64-linux-gnu/libstdc++.so.6
/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16
/usr/lib32/libstdc++.so.6
/usr/lib32/libstdc++.so.6.0.16
4

5 回答 5

2

尝试使用以下命令启动 MATLAB:

$ LD_PRELOAD=/usr/lib/libstdc++.so.6 matlab

(或系统上的实际位置)。

您还可以创建一个/lib64/libc.so.6指向它的符号链接

于 2013-04-25T16:54:55.863 回答
1

简单的解决方案,我没有检查最明显的事情:

$ sudo apt-get install libstdc++6-4.4-dev

于 2013-04-29T16:06:01.053 回答
1

我遇到了同样的错误,经过数小时尝试不同的解决方案后,看起来我发现了如何在我的情况下解决它。libstdc++.so.6解决方案是简单地从to创建一个符号链接libstdc++.so。所以: cd 到/usr/lib/x86_64-linux-gnu/并运行sudo ln -s libstdc++.so.6 libstdc++.so. 我希望它也适用于您的情况。

于 2016-11-04T00:34:44.220 回答
0

尝试安装软件包:

sudo yum install libstdc++-static

于 2013-07-27T14:24:12.000 回答
0

由于我没有评论的声誉,我想说@mafalda 的回答对我有用。我只需要在他的回答中将 4.4 替换为 4.7,因为我使用的是 gcc-4.7 编译器。即使是最新版本的 MATLAB(截至目前的 R2016a)也仅支持 gcc-4.7.x(而不是 4.8.x(目前是最新版本)),我想指出如果有人使用这个答案,只需将 4.4 替换为 4 .x 其中 x 取决于您的 gcc 编译器版本。

于 2016-06-06T14:49:49.333 回答