> I have created -- using xlC -- a shared library containing shared C++
> objects.
> One of these objects presents an extern "C" interface that wraps the C++
> classes.
> Programs compiled with xlc will link with the shared library with both xlc
> and xlC
> linking, but only the xlC linker works. We want to ship these libraries to
> customers
> who don't necessarily have the xlC compiler/linker.
> Can anyone tell me how to produce a C wrapper for a C++ class, such that the
> C
> wrapper is an the same shared library as the C++ class?
This should be no more difficult than writing 'extern "C" {}' code
around
your C interface routines, and compiling and linking them all into a
single
shared module. The extern "C" construct creates regular c linkage
(and symbol naming) for use by languages other than C++.
The real question is what is your command line for building the module?
On AIX dependent modules are named at link time, and even if your
customer
doesn't use xlC, your module already contains the dependency upon
libC.a/etc
and will be properly resolved.
In general, taking both C and C++ object code, your link command
should look something like
xlC -qmkshrobj -o foo.so cobj.o cppobj.o .... -L<whatever> -l<whatever>
...
Then examine the loader section of the module with dump -HTv and ensure
that
foo.so requires libC.a(shr.o) and others.
FYI you'll also want to specify a minimum level of the C++ runtime
for your customers, forcing them to update to current levels if
necessary.
--
Gary R. Hook / AIX PartnerWorld for Developers / These opinions are MINE
________________________________________________________________________