Closing DLL LIB

Started by Hardcoal, December 29, 2020, 07:57:50

Previous topic - Next topic

Derron

NG is creating .def files on its own if you compile dll files.


Bye
Ron

Hardcoal

Code

Derron

As said Brucey wrote a lot of little stuff when I asked him a while ago - as I was tinkering with interacting with DLLs and also compiling DLLs written in BlitzMax - including utilizing the GC (you need to call "initBRL()" in your DLL - ONCE).


bye
Ron

Hardcoal

#33
Ill check this initBRL() thing.. I have no idea what it does.. Im new in this Dll Area

anyway Ive made more fixes to this process

https://1drv.ms/u/s!ArSvOuhm7L3kr5c-rKPPA2hc7miivw?e=VaP2vl
Code

Derron

If you do rely on Garbage Collection in your DLL, then the GC only works if you initialized it in the DLL - which requires the (one time only) call to InitBRL().

As you do not know which function in your DLL is called as first, I did a "if not initBRLdone then init()" with "init()" doing "initBRLDone = True" and "InitBRL()".
That way each of my functions was able to rely on the GC cleaning up stuff and not leaking memory.


bye
Ron

col

QuoteAs you do not know which function in your DLL is called as first, I did a "if not initBRLdone then init()" with "init()" doing "initBRLDone = True" and "InitBRL()".

How come this is not in the dll startup stub if it's important to have?
https://github.com/davecamp

"When you observe the world through social media, you lose your faith in it."

Hardcoal

I dont know how to do this Init brl anyway..
please post example.. Derron..
Code

Derron

Quote from: col on January 07, 2021, 10:54:48
How come this is not in the dll startup stub if it's important to have?

It is only important if you need the GC stuff. And threads...
You better ask Brucey why he did it the way it is now - I had the issues with "no GC in the DLL" in the past and he came up with the solution to it

Further insight in these old issue:
https://github.com/bmx-ng/bcc/issues/366



@Hardcoal

Code (BlitzMax) Select

Global versionPtr:Byte Ptr = "Version 0.1.2.3 [2021/01/07]".ToCString()

'Retrieve string with name, version and build date
'returns: Pointer to a constant string
Function MyDLL_GetVersion:Byte Ptr() Export "Win32"
InitDLL()
Return versionPtr
End Function

'other functions you export


'other functions you export


....

' =============================
' === DLL STARTUP FUNCTIONS ===
' =============================
Global dllInitDone:Int = False
Function InitDLL:Int()
If dllInitDone Then Return True

InitBRL()
dllInitDone = True
Return True
End Function


Every function I use simply runs "InitDLL" - yes this is costing a bit (the function call + an number comparison) but was the easiest solution for me.


bye
Ron

Hardcoal

Code