在 64 位 Ubuntu 上编译 x32 位LD_PRELOAD

Compiling x32 bit LD_PRELOAD on 64 bit Ubuntu

本文关键字:LD x32 PRELOAD Ubuntu 编译      更新时间:2023-10-16

我正在尝试在x64平台(Ubuntu)上编译x32 LD_PRELOAD,我的命令:

g++ -fPIC -m32  -shared -Wl,-soname,test.so -ldl -o test.so test.cpp

但是我收到错误:

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

我该如何解决这个问题?谢谢!

您需要安装发行版提供的 32 位开发包。 您看到此错误是因为您没有要链接的 32 位 libstdc++。

尝试安装 Ubuntu 的 g++-multilib 软件包。