C Headsup: Compiling C++ code with GCC while linking against system libraries that use RTTI

While it seems that GCC and Clang get along fairly well even when linking against C++ code build with the opposing compiler they don't seem to agree on RTTI (which is mostly used to implement dynamic_cast i think). So when the application compiled with g++ calls into a system library (likely build by Clang) that tries to do a dynamic cast it will crash at a position kind of like this:

Program received signal SIGSEGV, Segmentation fault.
0x0000000802efba18 in vtable for __cxxabiv1::__si_class_type_info () from /lib/libcxxrt.so.1

The only way to fix this seems to tell GCC to use Clangs C++ library and headers by using the following flags:

CXXFLAGS+=-nostdinc -nostdinc++ -I/usr/include/c++/v1 -I/usr/include -I/usr/local/include

LDFLAGS+=-nodefaultlibs -lc++ -lcxxrt -lthr -lm -lc -lgcc_s

If your application uses intrinsics you need to add the appropriate GCC header files to the search path though as GCC will bark when trying to use Clangs intrinsic headers:


Obviously you need to adjust that path to include the appropriate versions and architecture.

Hope that saves someone a bit of time debugging.
Hello, I am getting something similar for months. Now my server is down because I am unable to renew my certificates with certbot (the let'sencrypt free service) This is the error I am getting.

* ob
object  : <refcnt 0 at 0x802d13ba0>
type    : str
refcount: 0
address : 0x802d13ba0
* op->_ob_prev->_ob_next
object  : <refcnt 0 at 0x802d13b9f>Segmentation fault

However, everything you have written up there, I don't understand. I am a non programmer.

Thanks so much. Any input will help.
I am sorry to say this but your problem is likely unrelated to the one described here. In any case what is the application that is giving you this error and how was it obtained (mostly in relation to if it was indeed compiled with gcc)?