Re: Informix C++ V2.5 library and GNU g++ compiler
Posted in 1999
On Tue, 2 Feb 1999, Uday wrote: > I am trying to use the C++ (version 2.5) client library (not CLI) on > a Solaris 2.5 system. > > I can successfully compile the example program using the Sun Workshop > compiler, but I get linker errors using the GNU 2.7.2.1 g++ compiler. > > Has anyone successfully managed to compile using the GNU compiler ? I doubt it. The GNU C++ compiler deliberately uses a different name mangling scheme from other C++ compilers, precisely to ensure that executables built with other compilers won't work with G++ and vice versa. This is because the G++ compiler probably makes different assumptions about the layout of objects, especially with respect to things like virtual pointers to virtual tables, the virtual tables themselves, and more complex things like virtual base classes. This is self-protection -- all hell would break loose if you were able to link code with different sets of assumptions. With C, the output of different compilers can be mixed into a single object because the rules for the layout of objects are sufficiently simple that there is seldom any problem. About the only conceivable way for there to be a problem is if one compiler is set up with 32-bit int and the other with 64-bit int types, or if one compiler uses more stringent alignment requirements than the other. However, the kernel interface (system calls) normally dictates the layouts (consider the stat(2) system call, for instance) so in practice this isn't a problem. C++ object code is sufficiently more complex than C object code and is still sufficiently new that there is no universal agreement on the layout of objects, so there is no uniformity in the C++ object code. Thank goodness that you can't link two incompatible sets of routines into a single program! Yours, Jonathan Leffler (jleffler@informix.com) #include <wish/I/was/skiing.h> Guardian of DBD::Informix v0.60 (v0.61_02) -- http://www.perl.com/CPAN Informix IDN for D4GL & Linux -- http://www.informix.com/idn