【问题标题】:Error compiling Matlab MEX files (Piotr's Matlab Toolbox)编译 Matlab MEX 文件时出错(Piotr 的 Matlab 工具箱)
【发布时间】:2013-02-17 07:31:04
【问题描述】:

我正在尝试安装 Piotr 的 Matlab 工具箱 (http://vision.ucsd.edu/~pdollar/toolbox/doc/),但 mex 文件的编译脚本抱怨:

>> toolboxCompile
Compiling.......................................

Warning: You are using gcc version "4.6.3-1ubuntu5)".  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/

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

mex: link of ' "/home/josh/Desktop/Project/code/toolbox/images/private/assignToBins1.mexglx"' failed.

??? Error using ==> mex at 222
Unable to complete successfully.

Error in ==> toolboxCompile at 36
for i=1:length(fs), mex([fs{i} '.c'],opts{:},[fs{i} '.' mexext]);
end

我该如何解决这个问题?

【问题讨论】:

  • 你安装g++了吗?看来你没有 C++ 库。

标签: matlab gcc ubuntu mex


【解决方案1】:
  1. 在你在 matlab 中编译 mexfiles 之前,你需要配置你的 mex 编译器。

    在 matlab 中输入:

    >> mex -setup
    

    Matlab 会自动检测您在计算机上安装了哪些编译器,并允许您选择其中一个。
    在 Linux 机器上你应该使用 gcc 编译器。

  2. 您必须注意的另一件事是确保您的环境变量 $LD_LIBRARY_PATH 指向您机器的库的安装位置。
    在 matlab 中你可以输入:

    >> getenv('LD_LIBRARY_PATH')
    

    并确保它是正确的。

  3. 尝试编辑 toolboxCompile.m 并将 -v 添加到 mex 编译命令中,以获取有关编译的更详细信息。

【讨论】:

  • 谢谢谢;其中一些信息非常有用。编译继续进行,但由于“未启用 SSE2 指令集”而进一步停止。
  • @Josh - 我不熟悉这个错误。上次我安装这个工具箱时,它在 Linux 和 Windows 上都很顺利。试试看工具箱本身是否有安装文档。
【解决方案2】:

如果您是 Linux(Ubuntu 但应该可以使用其他发行版)用户:

  1. 为了使用一些系统库而不是 Matlab 默认库,请将此环境变量添加到您的 bashrc (~/.bashrc):

    LD_PRELOAD=/lib/i386-linux-gnu/libc.so.6:/usr/lib/i386-linux-gnu/libstdc++.so.6:/lib/i386-linux-gnu/libgcc_s.so。 1;

  2. 安装g++-multilib:

    apt-get install g++-multilib

  3. 如果你在32位机器上运行编辑toolboxCompile.m文件并替换这行代码:

    "opts = {'-output'}" 与 "opts = {'CXXFLAGS=-msse2 -msse' '-output'}"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-11-30
    • 2014-01-31
    • 1970-01-01
    • 1970-01-01
    • 2014-10-28
    • 2014-05-29
    • 2022-10-12
    相关资源
    最近更新 更多