From: SourceForge.net <no...@so...> - 2003-11-20 04:19:38
|
Read and respond to this message at: https://sourceforge.net/forum/message.php?msg_id=2295810 By: mattkg0 Hi Guys, Im trying to build a DLL in Mingw that I can call from Visual Basic 6 however VB requires that that the calling convention used in the DLL is stdcall and thats where Im getting stuck. Ive been searching the web all day looking for an answer but unfortunately any stuff I dig up that seems remotely relevant is just horribly confusing to me. Anyhow I have my source file for the DLL (TestDLL.c) which contains: #ifdef BUILD_DLL #define DLLCALL __declspec(dllexport) #else #define DLLCALL __declspec(dllimport) #endif DLLCALL char TestCall1() { return(1); } DLLCALL char TestCall2(char Num1) { return(Num1); } DLLCALL char TestCall3(char Num1, char Num2) { char Num3; return(Num2 - Num1); } I build the DLL with: gcc -c -DBUILD_DLL -o TestDLL.o TestDLL.c dllwrap --output-lib=libTestDLL.a --dllname=TestDLL.dll --driver-mame=gcc TestDLL.o In my VB project I have all the Declare Function statements in a module which I thought would mean that I dont need to worry about def files or import libs (maybe thats where Im going wrong)? The external functions are declared as: Declare Function TestCall1 Lib "C:\mingw\source\Test DLL Call\TestDLL.dll" () As Byte Declare Function TestCall2 Lib "C:\mingw\source\Test DLL Call\TestDLL.dll" (Num1 As Byte) As Byte Declare Function TestCall3 Lib "C:\mingw\source\Test DLL Call\TestDLL.dll" (Num1 As Byte, Num2 As Byte) As Byte Now TestCall1 works fine when I call it from the VB application (most probably because it doesnt require any arguments) but when I call either TestCall2 or TestCall3 I get the following VB error: Run-time error 49: Bad DLL Calling Convention Ok, maybe the line: #define DLLCALL __declspec(dllexport) should be: #define DLLCALL __declspec(dllexport) __stdcall But when I recompile the DLL and run the VB app again I get another error this time: Run-time error 453: Cant find DLL entry point TestCall2 in C:\mingw\source\Test DLL Call\TestDLL.dll Ive read the documentation and FAQ on the mingw site but I still dont know where to go from here, should I be building the DLL with: gcc shared o TestDLL.dll TestDLL.c Wl,--output-def,TestDLL.def,--out-implib,libTestDLL.a Instead of using dllwrap? Do I need to create a def file by hand? Ive created a DLL and called it from another C application, but why is it so hard if I want to mix languages. I would appreciate any help as I'm very close to flying into a violent rage followed by tears. Thanks, Matthew. ______________________________________________________________________ You are receiving this email because you elected to monitor this forum. To stop monitoring this forum, login to SourceForge.net and visit: https://sourceforge.net/forum/unmonitor.php?forum_id=7134 |