Avoid linking to libstdc++

安稳与你 提交于 2019-11-30 01:16:24

When you compile, use g++ -c to compile only. Then for linking, use ld instead of g++. This invokes the linker directly, which requires you to name all your libraries on the command line (including libc and libcrt), however.

Alternatively, if you're using g++ as a "better c", you may be able to use gcc for your final link step (which will include libc automatically)

You could use

g++ -nodefaultlibs -fno-exceptions a.cc

But you cannot use all c++ features this way...

For the sake of completeness and correctness:

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