From: Jiri K. <jirikrivanek@BetaControl.cz> - 2003-01-28 10:42:36
|
Hi, the Delphi (it has been tested and it really works) uses the calling convention stdcall (Delphi specific keyword). From the Delphi help files I learned that the stdcall means: Directive: stdcall Parameter order: Right-to-left Clean-up: Routine Passes parameters in registers?: No Could you please tell me which one corresponds to the above mentioned specs in the GCC? Thank you very much, Kk. > The __stdcall calling convention requires the @nnn, if you don't have that, > it's not __stdcall, it's something else. > > __cdecl for example does not append anything, it just prepends a '_' in > front of the name. > > Mikael > > ----- Original Message ----- > From: "Jiri Krivanek" <jirikrivanek@BetaControl.cz> > To: "Mikael Aronsson" <mik...@te...> > Sent: Tuesday, January 28, 2003 11:21 AM > Subject: Re: [Mingw-users] DLLS > > > > Hi, > > > > does the stdcall with Mirrosoft compilers mean the same as with GCC? > > In case of positive answer, my calling conventions are not wrong as > > they were written by Microsoft itself (the headers are taken from the > > Microsoft SDKs and the headers do contain the stdcall - actually it > > is __stdcall - directive at all its functions). More, I checked that > > the Delphi port of the same headers uses the stdcall too. > > > > The question stays: How can I make compiler not to append those @n's > > to external symbols (sustaining the stdcall calling convention)? > > > > I do not know the exact reason for why the Microsofts GDIPLUS.DLL > > exports do not have those @n's (even if they use the stdcall > > convention). > > > > Will someone help? > > > > Thaks & best regards, > > > > Kk. > > > > > Hi ! > > > > > > The @n is appended to a function name when the calling convention is set > to > > > stdcall, @4 means as that the parameters use up 4 bytes, if you get this > in > > > your compiled code, then the calling convention is set wrong in your > > > function prototypes. > > > > > > Mikael > > > > > > ----- Original Message ----- > > > From: "Jiri Krivanek" <jirikrivanek@BetaControl.cz> > > > To: <Min...@li...> > > > Sent: Tuesday, January 28, 2003 8:54 AM > > > Subject: Re: [Mingw-users] DLLS > > > > > > > > > > > Hi Jiri, > > > > > > > > > > > > > > > "Jiri Krivanek" <jirikrivanek@BetaControl.cz> writes: > > > > > > How can I call the Mul() export of the KK.DLL? Please, do not > advice > > > > > > me to use the LoadLibrary() and the GetProcAddress() Windows APIs. > > > > > > There must be some other possibility. > > > > > > > > > > The quickest solution way is just adding the DLL to your link-line. > I > > > > > just created these files to check: > > > > > > > > > > >>>>>>>>>>>>> kkh.h > > > > > #ifndef KKH > > > > > #define KKH > > > > > > > > > > extern int Mul(int a, int b); > > > > > > > > > > #endif // KKH > > > > > <<<<<<<<<<<<< > > > > > > > > > > >>>>>>>>>>>>> kkh.c > > > > > #include "kkh.h" > > > > > > > > > > extern int __declspec(dllexport) > > > > > Mul(int a, int b) > > > > > { > > > > > return a*b; > > > > > } > > > > > <<<<<<<<<<<<< > > > > > > > > > > >>>>>>>>>>>>> kkh-user.c > > > > > #include <stdio.h> > > > > > #include "kkh.h" > > > > > > > > > > extern int > > > > > main() > > > > > { > > > > > printf( "2*2=%d\n", Mul(2,2) ); > > > > > return 0; > > > > > } > > > > > <<<<<<<<<<<<< > > > > > > > > > > With these files these command-lines worked: > > > > > > > > > > c:\tmp> gcc -shared -o kkh.dll kkh.c > > > > > c:\tmp> gcc -o kkh-user.exe kkh-user.c kkh.dll > > > > > c:\tmp> kkh-user > > > > > 2*2=4 > > > > > > > > > > > > > > > Another way to do it is to create import libraries for the DLLs in > > > > > question. The w32api sources have examples how to do that, see the > SF > > > > > download page (get there from > http://sourceforge.net/projects/mingw). > > > > > > > > > > > > > > > Hope this helps, benny > > > > > > > > > > > > > > > > > > Hello, > > > > > > > > thanx for your advices. I tried to and the elementary example works > > > > fine. But my problem is a bit different. The DLL I want to call in my > > > > program is not written by me, I have no sources of it and it even was > > > > not compiled by the gcc. > > > > > > > > When I use the above mentioned technique, I receive the following > > > > linker error message (please note that this is only one of many): > > > > ...:main.c: undefined reference to 'GdipDeletePen@4' > > > > > > > > If I understand well, this means that the LD linker is looking for a > > > > function named 'GdipDeletePen@4' (the @4 might mean the size of stack > > > > required for parameters ???) but in the given gdiplus.dll there is no > > > > such export. If I simply look into the binary image of the > > > > gdiplus.dll I will locate the string 'GdipDeletePen' instead. This > > > > means that I have to make the compiler not to append the @<xx> > > > > characters to (at least some certain) external names. Well I am going > > > > to scan through the compilers command line options (to avoid > > > > appending @<xx> globally) as well as consult the gcc manual (to avoid > > > > appending @<xx> for some certain externals only). > > > > > > > > Thank you all for helphing me & best regards, > > > > > > > > Kk. > > > > > > > > Ing. Jiri Krivanek > > > > Realtime applications programmer > > > > Beta Control s.r.o. > > > > Cerneho 58/60 > > > > 635 00 BRNO-Bystrc > > > > CZECH REPUBLIC > > > > tel.: +420 5 46 22 34 91 - 36 > > > > email 1: JiriKrivanek@BetaControl.cz > > > > > > > > > > > > > > > > ------------------------------------------------------- > > > > This SF.NET email is sponsored by: > > > > SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! > > > > http://www.vasoftware.com > > > > _______________________________________________ > > > > MinGW-users mailing list > > > > Min...@li... > > > > > > > > You may change your MinGW Account Options or unsubscribe at: > > > > https://lists.sourceforge.net/lists/listinfo/mingw-users > > > > > > > Ing. Jiri Krivanek > > Realtime applications programmer > > Beta Control s.r.o. > > Cerneho 58/60 > > 635 00 BRNO-Bystrc > > CZECH REPUBLIC > > tel.: +420 5 46 22 34 91 - 36 > > email 1: JiriKrivanek@BetaControl.cz > > > Ing. Jiri Krivanek Realtime applications programmer Beta Control s.r.o. Cerneho 58/60 635 00 BRNO-Bystrc CZECH REPUBLIC tel.: +420 5 46 22 34 91 - 36 email 1: JiriKrivanek@BetaControl.cz |