gpt4 book ai didi

matlab - 在 64 位 Ubuntu 12.10 中使用 32 位库编译代码的符号链接(symbolic link)

转载 作者:行者123 更新时间:2023-12-01 06:30:53 32 4
gpt4 key购买 nike

我正在尝试在 64 位 Ubuntu 12.10 上使用 32 位 2012a Matlab 混合 C 代码

我已经下载了所有可能的库(gcc 4.7、build-essential、libs-32 等)但是我收到以下错误

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libgomp.so when searching for -lgomp
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libgomp.a when searching for -lgomp
/usr/bin/ld: cannot find -lgomp
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status

我发现这个问题可以通过设置从 64 位库到 32 位库的符号链接(symbolic link)来解决。我尝试创建不同的链接,但无法完成编译。

提前谢谢你。

更新 1

gcc-multilib 丢失,所以之后

sudo apt-get install gcc-multilib 

我得到以下错误

Warning: You are using gcc version "4.7.2-2ubuntu1)".  The version
currently supported with MEX is "4.4.6".
For a list of currently supported compilers see:
http://www.mathworks.com/support/compilers/current_release/

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++
collect2: error: ld returned 1 exit status

我的 mexopts.sh 看起来像

CC='gcc'
CFLAGS='-ansi -D_GNU_SOURCE'
CFLAGS="$CFLAGS -fPIC -pthread -m32"
CFLAGS="$CFLAGS -fexceptions"
CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64"
CLIBS="$RPATH $MLIBS -lm"
COPTIMFLAGS='-O -DNDEBUG'
CDEBUGFLAGS='-g'
CLIBS="$CLIBS -lstdc++"

-m32 在那里,但是我不确定是否应该这样写。有人可以详细说明如何编辑 mexopts.sh 以使 matlab 查看 32 位库吗?

更新 2

看了Linking using g++ fails searching for -lstdc++之后

我尝试安装 g++-multilib

sudo apt-get install g++-multilib 

现在,错误的形式是:

/usr/bin/ld: i386:x86-64 architecture of input file `bin/fv_cache.o' is incompatible with i386 output
/usr/bin/ld: i386:x86-64 architecture of input file `bin/obj_func.o' is incompatible with i386 output
...

最佳答案

  • 首先确保您可以通过执行 gcc 从命令提示符构建 32 位可执行文件(更多信息在这里:32bit application on 64 bit Linux)
  • 在 matlab 命令提示符下执行 mex -setup 并选择 gcc 作为编译器。最后,您将收到有关“mexopts.sh”位置的消息(通常为 ~/.matlab//mexopts.sh)
  • 尝试“mex”。
  • 如果不成功,打开 mexopts.sh 并检查选项 -m32 是否在 CFLAGS 中。如果没有,请添加。

关于matlab - 在 64 位 Ubuntu 12.10 中使用 32 位库编译代码的符号链接(symbolic link),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14947557/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com