Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use a different STL with g++

Tags:

c++

gcc

stl

I want to use a different STL with g++ instead of its default libstdc++. What is the easiest way to do this?

I found -nostdinc++ flag which inhibits g++ from looking for its STL headers but this is only a compile time thing. It will still make g++ link against its own STL.

So I need to find a way to inhibit the linking.

Thanks!

like image 382
MK. Avatar asked Feb 01 '26 13:02

MK.


1 Answers

One easy method is to build with gcc rather than g++ - this won't link in the default C++ libraries, but will still compile .cpp files as C++ code. You will have to specify your alternative libraries explicitly on the command line.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!