OK, here's what I think the problem is but don't quote me on this ;)
The cppunit code uses a CPPUNIT_API
macro to wrap up
__declspec(dllexport)
and
__declspec(dllimport)
when building on Win32. It doesn't use the equivalent
__attribute__ ((visibility("default")))
for gcc
. This can cause problems when including that code in projects that do make use of the visibility attributes in gcc
, most notably when the project uses the gcc
command line flag
-fvisibility=hidden
to make all symbols private to the library by default and then using
__attribute__((visibility("default")))
in place of __declspec(dllexport/import)
where appropriate. If a symbol, such as a vtable, is marked hidden in just one library, even though it is marked public in all other libraries, then apparently (see the link below) it is marked hidden and you get a linker error.
In your case the linker warnings that you get initially suggest that zxingcore-tests
is being built with symbols hidden by default (check for that -f
option when it's building) whereas xzingcore
itself has them public. The symbols for the cppunit vtables will exist in cppunit
, zxingcore
and zxingcore-tests
but are marked hidden in zxingcore-test
and so they get hidden.
I think you need to try to find out why the zxingcore-tests
build is hiding symbols and prevent it from doing that.
For further reading try the gcc wiki visibility page, particularly the section on "Problems with C++ exceptions" (and follow the link about vague linkage in there as well which shows it applies to vtables too). I'm vaguely familiar with this stuff because I've been bitten by dynamic_cast
failures across libraries which, in that instance, are caused by the typeinfo
objects getting hidden by mistake.