On Mon, 21 Sep 2009, Maurilio Longo wrote: Hi,
> I'm at a good point, dll gets created so it does for the import library, but > when I start a program (I'm using hbtest after setting hb_build_shared=yes) I > get this error: > (E:\repository\harbour\bin\os2\gcc)hbtest > Unrecoverable error 9012: Can't locate the starting procedure: 'MAIN' > What can it be? I mean, am I missing some module from the building of the > .dll or what? There are few possible situations which can cause such behavior. They depend on OS behavior when shared library is loaded and also on shared library contents. In general hb_vmInit() was executed before executing startup code in static part of application which register user functions/procedures in HVM so HVM cannot find user MAIN() function/procedure (on some platforms is also looks for first registered func/proc with HB_FS_FIRST attribute) and generates above internal error. Now you have to find the reason of such behavior in OS2 DLLs created by GCC. Please remember that using different platform or C compiler may cause totally different behavior. I do not know OS2 but probably there are some analogies to MS-Windows. In Windows when DLL is loaded/unloaded special init/exit function is executed. The name of this function depends on used C compiler, it may be DllMain(), DllEntryPoint() or even WinMain(). Sometimes more then one is supported with different priority because linker attach to DLL CRTL wrapper with OS entry point which later calls some one of known startup functions in linked code so it can even execute main(). And this is the easiest explanation of your test results: just after loading DLL and before executing startup code from static part of application main() function was executed. In such case it's necessary to exclude mainstd.c from create .DLL file. Probably it will be necessary to exclude it from HVM and move it to hbmainstd.lib and link this library with final static or shared applications. We already make such tricks in some of MS-Windows builds. Just look at source/vm/Makefile. If startup code attached to harbour.dll executes only one startup function then it's possible that you will find other 'known' DLL startup function which has higher priority then main(). In such case it's enough to add such function to final DLL. We are using this method in some windows builds adding maindllh.c to final library (see source/vm/maindllh/Makefile). I hope that above is enough to find the solution. Please check. If it does not help then I'll ask you to make same small modifications in HVM code which shows executed startup code so we can see more precisely what exactly happens when you start shared linked application. best regards Przemek, _______________________________________________ Harbour mailing list [email protected] http://lists.harbour-project.org/mailman/listinfo/harbour
