Hi Ben, Thanks for pointing out the way to solve the "new" and "delete" problem. I have another question I confronted as how to implement the shared library when class concept are involved.
In my caller palm application, i included the header for a class A and declared a pointer to A at where I need to use this class. It seems I can call a shared lib function like CreateObjA to return an A object pointer, but when I pass this pointer back to an A member method wrapped in my lib, which meant to set a boolean type member variable of this A object, my caller application crashes and the error message saying the lib function is trying to access either unallocated mem, or the mem which is not allowed to access. It seems to me like the object allocated by the lib function CreateObjA is deallocated out of the scope of the CreateObjA so that the pointer I get becomes invalid when I try to use it second time and thus cause memory errors. I don't know whether this is true and if the shared lib cann't hold the memory chuck allocated for the object within the library space, how can I work around this problem? Please let me know for any clear points in my question. Thanks! Mengtao. ----- Original Message ----- From: "Ben Combee" <[EMAIL PROTECTED]> To: "Palm Developer Forum" <[EMAIL PROTECTED]> Sent: Monday, January 06, 2003 11:39 AM Subject: Re: Help needed to build a palm shared library > At 09:10 2003-1-6 -0500, you wrote: > >Dear All, > > > >I am using the Palm OS Shared Library Wizard of CodeWarrior 8.0 to create a > >shared library. I need to wrap several classes and their member methods > >written in C++ in this shared library project. I am tring to call the method > >functions of the classes in my wrapper functions as the entries for the > >shared library dispatch table. However, I got link error saying the "new" > >and "delete" are not defined as some of the method functions uses them. > > new and delete can be defined in several ways. There is an implementation > in the PalmOS_Runtime lib files, but the shared library wizards only > includes one runtime source file by default. > > You can try adding PalmOSRuntime_2i_A5.lib to your project file, and you'll > pull in the correct definitions of new and delete. You shouldn't get > anything else from the runtime, since shared libraries have their own entry > point. > > >I go to project setting, 68K Target setting, and set the Project Type from > >Palm OS Code Resourse to Palm OS Static Library, and build the project > >again. For this change, I don't get the link error complaining about "new" > >and "delete". But it's wrong to do this because the Project Type of shared > >lib is required to be set as Palm OS Code Resourse. > > Static libraries are just collections of unlinked code -- the .lib files > included with CW are made using this mode. > > -- > Ben Combee <[EMAIL PROTECTED]> > CodeWarrior for Palm OS technical lead > Palm OS programming help @ www.palmoswerks.com > > > -- > For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/ > -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
