On 24 Sep 2001, at 15:46, ANURADHA Srinivasan wrote:
Hello ,
We tried compiling a DLL with the following sources but have not been successful.
program mycall; function add(x:integer;y:integer):integer; far; external 'mylib';
[...] That is Delphi syntax. Doesn't work with GPC.
library mylib;
[...] GPC doesn't understand "library".
uses winprocs; function add(x:integer;y:integer):integer;export; begin add:=x+y; end; exports add index 1; begin end.
What changes do we have to make to the sources to build the DLL?
Building a DLL with GNU tools is not for the fainthearted. Mumit Khan explains all the magical rites at: http://www.xraylith.wisc.edu/~khan/software/gnu-win32/dllhelpers.html
I have an application (a front end to GPC that uses .cfg files like Delphi and Borland Pascal) in which I have tried to make provision for building DLLs with a simple switch ('--dll'). This works somewhat and succeeds in producing a DLL, and a '.a' library containing the DLL exports. However, it has been a pain to get GPC to successfully link to this '.a' file with 'external' and 'asmname' declarations. GPC can load the DLL routines using 'LoadLibrary', as long as the DLL functions are not compiled with the 'Stdcall' attribute. This of course means that only GPC can use the DLL (not good). On the other hand, Delphi can load the DLL routines using 'LoadLibrary' if the functions are compiled with the 'Stdcall' attribute - which is the norm for Win32 DLLs; but then GPC can't load the DLL functions successfully, even using 'LoadLibrary'. So something is obviously amiss somewhere (more likely, there is something that I have not understood properly).
Anyway, so far, everything depends on the applications that you intend to use your DLL. My program is LGPLed. The current development version is a bit untidy, but if you want a copy of the sources, you are welcome.
Best regards, The Chief --------- Prof. Abimbola Olowofoyeku (The African Chief) Author of Chief's Installer Pro for Win32 Email: African_Chief@bigfoot.com http://www.bigfoot.com/~african_chief/