Occi Linkage Error with Gcc 5

OCCI linkage error with gcc 5

This is almost certainly due to incompatibility between the new ABI in gcc 5 and the ABI expected by the OCCI libraries.

  • The OCCI libraries were apparently created using gcc 4.x
  • gcc 5 introduces a new ABI which includes, among other things, the "short string optimization" for std::string, and is compatible with C++11 (which disallows the reference-counted implementation of std::string used in gcc 4.x).

You can try #defining _GLIBCXX_USE_CXX11_ABI to 0 before building your code, which will cause gcc 5 to use the old ABI.

  • Note that EVERYTHING must be compiled with the same ABI to work together, so you may want to make that setting a global build flag. (E.g., with CMake, you would add -DCMAKE_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=0" to the CMake command line).

Also, note that a similar problem exists when trying to build using OCCI with clang and its implementation of libc++ (http://libcxx.llvm.org/). (This is the one that bit me).

You can find out more at: https://gcc.gnu.org/gcc-5/changes.html#libstdcxx and https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html

How to link with specific library ( g++; libstdc++.so.5 and libstdc++.so.6 )

Here's the ABI versions table; the default value for the -fabi-version switch changed from 1 to 2 at the same time g++ introduced libstdc++.so.6 with 3.4. This means that to link against the older libstdc++ library you would need to

  • find and use the equivalent C++ headers instead of the ones included with your compiler
  • recompile all your code (and any other C++ libraries you're using) with -fabi-version=1

otherwise you run the risk of ABI incompatibilities. I can't tell you precisely what the changes were but in general it's best to try and keep all C++ code you have compiled with the same compiler version.

Assuming you don't want to try and hack things togther like this I think you have two choices:

  1. ask your shared library vendor to recompile the library with your version of GCC for you. This may not be trivial as g++ 3.4 introduced a new stricter C++ parser.
  2. ask your vendor which version of g++ they used to compile the library in the first place and use that version to compile your own code. RH might provide a compat-gcc compiler as well as the libstdc++ - I can't remember. However you'll also need down-level versions of all other libraries and OS-provided C++ libraries that you're using, so might be easiest to compile on a VM with an older Red Hat version that had the right compiler.

Is it possible to compile/link to occi with gcc on HPUX?

No, there isn't a way around that.

Different C compilers have interchangeable code using a standard ABI. You can mix and match their object code more or less with impunity.

However, different C++ compilers have a variety of different conventions that mean that their object code is not compatible. These relate to class layout (especially in multiple inheritance hierarchies and the dreaded 'diamond-of-death'), but also in name mangling conventions and exception handling. The name mangling schemes are deliberately made different so that you cannot accidentally link objects from one compiler with another.

Generally, if libraries are built using a C++ compiler, you have to link your code using the same - or at least a compatible - C++ compiler. And that almost invariably means a compiler from the same family. For example, you might be able to use G++ 4.5.0 even if the code was built with G++ 4.4.2. However, you won't be able to mix aCC with G++.



Related Topics



Leave a reply



Submit