在 64 位 Ubuntu 上编译 x32 位 LD_PRELOAD

Rob*_*ert 1 c++ 64-bit compilation ld-preload

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

g++ -fPIC -m32  -shared -Wl,-soname,test.so -ldl -o test.so test.cpp
Run Code Online (Sandbox Code Playgroud)

但我收到错误:

/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
Run Code Online (Sandbox Code Playgroud)

我该如何解决?谢谢!

cdh*_*wie 5

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

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