Linking gcc compiled binaries and non-gcc libraries
Vardhan, Sundara (GE Infra, Energy)
sundara.vardhan@ge.com
Thu Jan 29 16:18:00 GMT 2009
Hi John
Thank you very much for the below information. I think I will get the 3rd party libraries compiled with g++ from the vendor. That will definitely save me time.
With Regards
Vardhan
-----Original Message-----
From: John (Eljay) Love-Jensen [mailto:eljay@adobe.com]
Sent: Thursday, January 29, 2009 10:56 AM
To: Vardhan, Sundara (GE Infra, Energy); GCC-help
Subject: Re: Linking gcc compiled binaries and non-gcc libraries
Hi Vardhan,
GCC and other compilers, such as Sun or AIX, can cross-link C ABI.
GCC and other compilers, such as Sun or AIX, cannot cross-link C++ ABI.
If you need to cross-link to a C++ library you need to create a C API thunk layer to bridge from GCC C++ to Sun or AIX C++. You¹ll need to compile the Sun or AIX side of the C API thunk to the Sun/AIX C++ code with the Sun or AIX compiler. Then your GCC C++ code needs to use the C API thunk.
The C API thunk is responsible for marshalling parameters (if they are more complicated than a plain old data type, such as a std::vector), and for handling exceptions that may arise on the Sun/AIX C++ side of the fence.
Other issues that may arise is if the Sun/AIX C++ library uses C++ I/O.
Even moreso if that C++ I/O object is used in its API -- that makes things a lot more difficult.
This is not a GCC issue. Rather, it is the lack of a C++ ABI standard to which the various C++ compiler vendors can comply. (There is a C ABI standard for almost all platforms specified by the respective platform¹s OS, to which all the various C compiler vendors do comply.)
HTH,
--Eljay
More information about the Gcc-help
mailing list