"Randy Eaton" <[EMAIL PROTECTED]> wrote in message
news:52415@palm-dev-forum...
>
> I have developed an extensive amount of C++ code that I would like
to move
> to a shared library rather than be linked into each application. Does
anyone
> know how I would go about this?
> All of the examples I've seen are straight C code but there must
be some way
> to do it.
With standard system shared libraries, you aren't able to do this
easily.
1) All calls to shared libraries go through a library dispatch
mechanism. This requires the leading argument of the shared library
call to be a reference to the library. This clashes with C++'s use of a
hidden first argument to hold the "this" pointer.
2) Palm shared libraries don't have global variables. Virtual tables
for C++ classes are stored in globals, so you can't use dynamic
dispatch.
It might be possible to do non-dynamic classes in a shared library, but
no methods would be visible across the shared library boundary -- you
would need plain C wrapper functions to provide access to the classes.
With the GCC toolset, you might be a little more successful, as they can
create GLib shared libraries, which are floating code resources that get
locked into position and accessed through a stub library that handles
the dispatch correctly. These use globals through a different pointer
which gets fixed through the call stubs. CW's compiler can't generate
these right now because there is no A4-globals switch, though we're
looking into the issues involved in proper support for a future release.
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/