Linking using g++ fails searching for -lstdc++

微笑、不失礼 提交于 2019-11-28 18:18:38

Posting for future reference, a solution I found was to install g++-multilib. I had the same incompatible problem relating to -lstdc++ on g++ version 4.6.1

On further probing: g++-multilib is a dummy package which installed g++4.6-multilib which in turn installed the appropriate libstdc++.so under the /usr/lib/gcc/x86_64-linux-gnu/4.6/32 folder.

Answering my own question:

Ths solution seems to be a bit of a hack, you need to create a symlink for the 32 bit version of the library (after installing the packages mentioned in @nos's answer):

$ sudo ln -s /usr/lib32/libstdc++.so.6 /usr/lib32/libstdc++.so

Once you've done this, the linker will automagically find the correct library to use.

It seems you're compiling a 32 bit library on a 64 bit machine, however a 32 bit version of libstdc++ is not present.

Try apt-get install ia32-libs libc6-i386 libc6-dev-i386 lib32gcc1 lib32stdc++6

(btw. you're producing a .so , you should specify -fPIC when compiling your .cpp files as well)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!