[odb-users] Undefined symbol with GCC 4.7.0

Boris Kolpackov boris at codesynthesis.com
Thu May 3 07:28:03 EDT 2012


Hi Miguel,

Miguel Revilla Rodríguez <yo at miguelrevilla.com> writes:

> This is my first post so let me a small OT to thank you for this great
> piece of software.

Thanks, I am glad you like it!


> Now, I've compiled odb 2.0.0 with gcc 4.7.0 and everything went fine 
> while compiling, but execution has this outcome:
> 
> (person.h is the one from the Hello World example):
> 
> $ odb -d mysql --generate-query person.h
> cc1plus: error: cannot load plugin /usr/bin/odb.so
> /usr/bin/odb.so: undefined symbol: _Z20ggc_round_alloc_sizem

We ran into a similar issue ourselves. Apparently, GCC 4.7 uses a C++
compiler instead of C to build itself. One consequence of this change
is that all the symbols become mangled. In 2.0.0 we addressed this by
including plugin headers as extern "C" for GCC 4.6 and earlier and
as C++ for GCC 4.7 and later.


> $ gcc --version
> gcc (GCC) 4.7.0 20120414 (prerelease)

Perhaps it is the prerelease part that's causing the problem. ODB builds
and runs fine with the final GCC 4.7.0 on my Debian box. To verify this,
can you check the contents of the bversion.h header in the plugin include
directory. To find out its location, run:

g++ --print-file-name=plugin

The bversion.h file should be in the include/ subdirectory. On my Debian
box with GCC 4.7.0 it looks like this:

#define BUILDING_GCC_MAJOR 4
#define BUILDING_GCC_MINOR 7
#define BUILDING_GCC_PATCHLEVEL 0
#define BUILDING_GCC_VERSION (BUILDING_GCC_MAJOR * 1000 + BUILDING_GCC_MINOR)

If it has something other than 7 for BUILDING_GCC_MINOR, then that would
be a problem and upgrading to the final release should fix it (you will
need to re-build ODB though).

Boris



More information about the odb-users mailing list