BMX-NG MinGW/GNU and C/C++ DLLs
BlitzMax Forums/Brucey's Modules/BMX-NG MinGW/GNU and C/C++ DLLs
| ||
| I have done some basic C/C++ file imports but I was wondering how do you compile and link external DLLs, particularly int,float,string functions that takes a number of parameters and with the same int,float,or string type. I only found Visual C++ Solutions so far for Vanilla. |
| ||
| You have a C++ DLL that you want to use with BlitzMax? If it has been built with VS++ then you'll need to build a C-glue dll in VS and link your BlitzMax code to that - because VS and GCC C++ ABIs on Windows are not compatible. |
| ||
| Thanks, yes of course I will be using the same MinGW that I use with the NG. Anyway I think I figured it out but maybe if you still have some tips.. I got the C side example from here to test: http://www.transmissionzero.co.uk/computing/building-dlls-with-mingw/ C Code: /* add_basic.c
Demonstrates creating a DLL with an exported function, the inflexible way.
*/
__declspec(dllexport) int __cdecl Add(int a, int b)
{
return (a + b);
}MinGW DLL Creation: gcc -c -o add_basic.o add_basic.c gcc -o add_basic.dll -s -shared add_basic.o -Wl,--subsystem,windows BMX Code:
SuperStrict
Global Add:Int(a:Int,b:Int) "Win32"
Local lib:Byte Ptr = LoadLibraryA("add_basic.dll")
If lib = 0 Then
Notify "DLL-file not found!"
Else
Add = GetProcAddress(lib, "Add")
EndIf
Print Add(2,3)
EndI tested only C but I guess that's where the C++ glue part you mentioned comes in. Edit: Updated Post Title |