Alien-Build icon indicating copy to clipboard operation
Alien-Build copied to clipboard

Static compilation can fail with mixed C and C++ code

Open thibaultduponchelle opened this issue 4 years ago • 0 comments

When building statically, the C compiler seems like to be more "rude" to discard symbols or namespaces (I think I read this somewhere but not able to find the link again right now).

In the problem reported here I got some "undefined reference to `std::nothrow'" like if the libstdc++ was not loaded.

cc file.c using libfoo that contains at some point some c++ code

This is related to the problem with libgearman reported here

I first thought about naming collision introduced by static compilation then investigated the mixed C and C++ code (starting to try to add "extern C" code).

I used make -n | grep partition | grep examples to find the actual command line used to compile the failing c file then tried and validated the solution (C++ compiler and -lstdc++)

Some doc that I read : Mixing C and C++ code -> recommend to compile and link with C++ compiler Static linking collision -> Not really what we have here CPPGuess -> Same kind of related heuristics

I don't see really a way to handle it in AB, but report it upon request to keep a trace or eventually for adding some documentation.

thibaultduponchelle avatar Jul 16 '20 07:07 thibaultduponchelle