Carl,
Thanks for the reply.
The only difference between the library that is experiencing the load faults,
and the library that is loading successfully is that the C++ library (the Xerces
library) is one of libraries with which my TCL package library is being linked.
The code used to make up the shared library (written in C and compiled with a
C++ compiler) has its function definition statements in and extern "C" block,
and if linked without reference to the Xerces C++ library, loads successfully
into TCL and creates my simple TCL command. This code is very simple, and makes
NO USE of the C++ code in the Xerces C++ library.
However, if without even recompiling the source (so using the same object file
that worked previously) I re-link my TCL package shared library, adding the
Xerces C++ library into the list of libraries to be linked in, the link is OK,
(as all of my PATHs are OK), but when I try to load it into TCL, I get the
unresolved symbol and unresolved module errors detailed in the email below.
My feeling is that the HP-UX 11 C++ compiler (aCC) makes reference to these
symbols and modules when compiling C++ to object code, and assumes that aCC will
be used to link (if an executable - hence the samples all work fine), or that
aCC has been used to build the executable with which the shared library is to be
associated.
I'm going to try to build TCL using the aCC compiler and see how I get on.
I'd particularly like to hear from anyone involved in the Xerces C++ integration
into TclXML, if anyone out there was involved. On the Sourceforge site, there is
no documentation regarding the Xerces integration into TCL, and the distribution
seems incomplete (the Xerces module doesn't have a config directory or a
configure file). My guess is that anyone involved in that work would know how to
get round the problems I have been experiencing.
If you, or anyone else out there has any idea about what to do, I'd appreciate
the help.
Thanks
Kev Shaw
[EMAIL PROTECTED] on 17/10/2001 19:14:23
To: <[EMAIL PROTECTED]>
cc:
Subject: Re: Problems with Xerces / TCL integration
Kevin,
Thought I'd jump in here.
C programs can't call C++ libraries, because of the name mangling used in
the C++ language, which is required to provide template support. However,
you can force the functions to be considered C functions, even though they
are compiled with a C++ compiler, by declaring the functions as 'extern "C"
{ .... }'.
However, the code within the { } must be C code, not C++. That code can
call C++ functions in the same library, because it was compiled with a C++
compiler, and will understand the name mangling.
So you need C functions that wrap the entrypoints to your reall C++
functions. Once you do this, it can be called from either C++ or C.
It's a little tricky to grasp the concept, but once you understand what's
going on under the covers, it's pretty simple. I'm just not very good at
explaining it.
Some C++ compilers also have a switch or a pragma that turns off name
mangling for individual functions, and you can use that too, but only if
the function doesn't have overloading, since C doesn't understand
overloading, and won't know how to handle duplicate function names. It will
just complain about the duplicate functions with different parameters.
I've had to do this for my own code. Remember, UNIX was written in C, not
C++, so it doesn't have any way to use a C++ library unless you wrap it in
C functions. Of course, C++ programs that use the library directly don't
have that problem.
Hope this helps, -- it's probably clear as mud ;-)
--Carl
"Kevin Shaw" <[EMAIL PROTECTED]> on 10/17/2001 12:52:24 PM
Please respond to [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
cc:
Subject: Problems with Xerces / TCL integration
Hi,
I have written a simple TCL package in C++ (on a HP running HP-UX 11). This
file
contains the package init procedure and a simple command. There are no
references to the Xerces API within the code. This package is made
available as
a shared library.
The final application will (I hope) make use of the Xerces parser. I have
therefor added the Xerces shared library as one of the libraries to load as
part
of loading my application shared library (i.e. included it in the link
stage of
the compilation).
However, when I load, I get the following load failure messages:
/usr/lib/dld.sl: Unresolved symbol: __ZStaticCtorTable_Start (data) from
/usr/lib/libCsup.2
/usr/lib/dld.sl: Unresolved symbol: __ZStaticCtorTable_End (data) from
/usr/lib/libCsup.2
/usr/lib/dld.sl: Unresolved symbol: __StaticCtorTable_Start (data) from
/usr/lib/libCsup.2
/usr/lib/dld.sl: Unresolved symbol: __StaticCtorTable_End (data) from
/usr/lib/libCsup.2
/usr/lib/dld.sl: Unresolved module for symbol: __shlinit (code) from
/usr/lib/libstream.2
couldn't load file "../lib/libxmlgenxerces.sl": unresolved symbol name
(libxmlgenxerces.sl is the name of the library containing the TCL apckage
to be
loaded).
The tclsh I am loading it into was built using a C compiler (not the C++
compiler). I think that this might have something to do with it - but am
not
sure.
When this same library is linked with the executable samples (linked with
the
C++ compiler), then there are no problems.
Anyone got any ideas about what I need to do ?
Kev Shaw
Tertio Limited - One Angel Square, Torrens Street, London EC1V 1PL
Tel: +44 (0)207 843 4000 Fax: +44 (0)207 843 4001 Web http://www.tertio.com
Any views expressed in this message are those of the individual sender,
except where the sender specifically states them to be the views of Tertio
Ltd.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]