You can only export Functions from a dll
Not quite, globals can also be exported, it's just important that the caller now needs to refer to the symbol as pointer.Here's an example:
DLLTest.bmx:
Strict Framework brl.blitz Global VariableDLLTest.def:
EXPORTS Variable=bb_VariableDLLCaller.bmx:
Strict Framework brl.blitz Import pub.win32 Local Library = LoadLibraryA ( "DLLTest.dll" ) If Not Library WriteStdout "Library not found!~n" Return EndIf Local Variable Ptr = Int Ptr GetProcAddress ( Library , "Variable" ) If Not Variable WriteStdout "Variable not found!~n" Return EndIf Variable [ 0 ] = 53 WriteStdout "Variable is " + Variable [ 0 ] + ".~n" FreeLibrary Library Extern "Win32" Function FreeLibrary ( Library ) EndExternThe calling instance always needs to use the [0] when accessing the variable. If I remember correctly, it was in version 1.12 or 1.14 where you could write:
Local Variable Var = Var Int Ptr GetProcAddress ( Library , "Variable" )and then you could access the variable as normal, so "Variable = value" to write and "Variable" to read values, without any need for [0] - but this feature disapeared since version 1.18 I think.
The only thing that can't be exported from dlls are types and objects, the problem is that the type would either exist twice, once in the dll and once in the main programm, or the caller couldn't access the object's fields and methods because it has no declaration of the types.
P.S.: I'm sorry, I've forgotten to tell you about copying the dllcrt2.o file, but Khomy Prime explained it perfectly.