At 11:14 AM 1/11/00 -0500, you wrote:
> I am trying to create a shared library that contains C++ classes,
however, the
>front interface is straight function calls
>Now everytime I enable the C++ compiler option (even on the sample Lib
that came
>with codewarrior) I get the following linker error
>
>Link Error : __RuntimeModule__: '__Startup__' referenced from
>'__DummyStartup__' is undefined.
>
>How can I get rid of this problem? Can I get rid of this problem? or am I
>restricted to use C only for Shared libraries...
Enabling the C++ compiler option activates name mangling. This is where
the compiler changes your function names to include information about
parameters, classes and stuff. If you declare your startup function as
extern "C" __Startup__ ( );
this should eliminate your problem. Bear in mind, though, that both the
Palm example and the example from my Dr. Dobbs article macro __Startup__ to
something else:
#define LibInstall __Startup__
extern "C" Err LibInstall(UInt refNum, SysLibTblEntryPtr entryP);
Is how I do it.
You can use C++ in shared libraries, there are some restrictions:
1. The public API (the one called by clients of your library) *must* be C
functions and should be declared as extern "C". This handles the
name-mangling problem mentioned above.
2. You can't use any virtual functions. Virtual functions generate virtual
tables which are stored in the library's global memory space.
Unfortunately, shared library's don't have global memory space so your app
will crash.
That's all I can think of offhand. I just don't use C++ in shared
libraries and everything is good.
Regards,
Greg
Greg Winton
Bachmann Software and Services, LLC
http://www.bachmannsoftware.com
Software for Handheld & Wireless Computing
Authors of "Palm Programming", published by Macmillan/Sams
Home of Bachmann Print Manager, the only graphical printing solution for
the Palm
Computing Platform