Working with a large piece of code that I can't currently break down into an MCVE, so I'll do my best.
I'm working with a large project that is compiled as a static library, libfoo.a
. A separate project, bar
, links against that library. The "offending" snippet in libfoo
is as follows:
class Base {
public:
void foo(){}
void bar(){}
};
class Derived : private Base {
public:
using Base::foo;
};
Both libfoo
and bar
make extensive use of boost. bar
has to be compiled with -std=c++11
due to C++11 features it makes use of, but libfoo
can be compiled with minimal options (i.e. the default compiler options used by GCC v4.8, which appears to be -std=c++0x
-std=gnu++03
).
When I attempt to link bar
using a GCC defaults compiled -std=c++0x
libfoo.a
, it fails with a lengthy, name-mangled warning, which reduces to:
Undefined reference to Base::Derived::foo()
When I re-build libfoo.a
with -std=c++11
, this issue no longer occurs.
I compared the output of libfoo.a
via nm and in both cases, the appropriate symbols were present. I've also gone through the Cxx11Abi compatibility documents, and it doesn't appear that this compiler setting should "break" compatibility.
What is the cause of this linker issue?
As MartinBonner notes, it had to do with namespace changes to types that were used in function prototypes. The only solutions were to either compile via -std=c++11
or re-write massive amounts of code to have an extra layer of "abstraction" around the type.