在 Kubuntu 上构建 MEX 文件 (MATLAB 2012a) 时出错“/usr/bin/ld: 找不到 -lstdc++" [英] Error building MEX-files (MATLAB 2012a) on Kubuntu '/usr/bin/ld: cannot find -lstdc++'

查看:27
本文介绍了在 Kubuntu 上构建 MEX 文件 (MATLAB 2012a) 时出错“/usr/bin/ld: 找不到 -lstdc++"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过以下命令在 Matlab 2012a 上构建 C 程序:

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

mex mat_trans2.c

mex mat_trans2.c

我收到此错误:

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

前段时间我能够构建.c文件,我不知道现在发生了什么!也许在我的 Kubuntu 12.04 64 位系统升级后发生了一些变化.

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?

谢谢!!!!

我编辑了消息以在 Shai 上回复.运行:

I edit the message to reply at Shai. Running:

mex -v mat_trans2.c

mex -v mat_trans2.c

我明白了:

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

我会说问题是/lib64/libc.so.6:找不到

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

加:

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

推荐答案

琐碎的解决方案,我没有检查最明显的东西:

Trivial solution, I hadn't check the most obvious thing:

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

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

这篇关于在 Kubuntu 上构建 MEX 文件 (MATLAB 2012a) 时出错“/usr/bin/ld: 找不到 -lstdc++"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆