January 16, 2021, 10:11:22 PM

Author Topic: Closing DLL LIB  (Read 915 times)

Offline Derron

  • Hero Member
  • *****
  • Posts: 3331
Re: Closing DLL LIB
« Reply #30 on: January 06, 2021, 06:59:22 AM »
NG is creating .def files on its own if you compile dll files.


Bye
Ron

Offline Hardcoal

  • Hero Member
  • *****
  • Posts: 531
  • nothing is personal
Re: Closing DLL LIB
« Reply #31 on: January 06, 2021, 01:24:26 PM »
Now I know that..

Lets make the world a better place

Offline Derron

  • Hero Member
  • *****
  • Posts: 3331
Re: Closing DLL LIB
« Reply #32 on: January 06, 2021, 02:02:51 PM »
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

Offline Hardcoal

  • Hero Member
  • *****
  • Posts: 531
  • nothing is personal
Re: Closing DLL LIB
« Reply #33 on: January 06, 2021, 02:54:33 PM »
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
Lets make the world a better place

Offline Derron

  • Hero Member
  • *****
  • Posts: 3331
Re: Closing DLL LIB
« Reply #34 on: January 06, 2021, 03:24:03 PM »
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

Offline col

  • Sr. Member
  • ****
  • Posts: 474
Re: Closing DLL LIB
« Reply #35 on: January 07, 2021, 10:54:48 AM »
Quote
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()".

How come this is not in the dll startup stub if it's important to have?
To be is to be perceived.

https://github.com/davecamp

Offline Hardcoal

  • Hero Member
  • *****
  • Posts: 531
  • nothing is personal
Re: Closing DLL LIB
« Reply #36 on: January 07, 2021, 11:13:25 AM »
I dont know how to do this Init brl anyway..
please post example.. Derron..
Lets make the world a better place

Offline Derron

  • Hero Member
  • *****
  • Posts: 3331
Re: Closing DLL LIB
« Reply #37 on: January 07, 2021, 11:49:25 AM »
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
  1. Global versionPtr:Byte Ptr = "Version 0.1.2.3 [2021/01/07]".ToCString()
  2.  
  3. 'Retrieve string with name, version and build date
  4. 'returns: Pointer to a constant string
  5. Function MyDLL_GetVersion:Byte Ptr() Export "Win32"
  6.         InitDLL()
  7.         Return versionPtr
  8. End Function
  9.  
  10. 'other functions you export
  11.  
  12.  
  13. 'other functions you export
  14.  
  15.  
  16. ....
  17.  
  18. ' =============================
  19. ' === DLL STARTUP FUNCTIONS ===
  20. ' =============================
  21. Global dllInitDone:Int = False
  22. Function InitDLL:Int()
  23.         If dllInitDone Then Return True
  24.        
  25.         InitBRL()
  26.         dllInitDone = True
  27.         Return True
  28. End Function
  29.  

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

Offline Hardcoal

  • Hero Member
  • *****
  • Posts: 531
  • nothing is personal
Re: Closing DLL LIB
« Reply #38 on: January 07, 2021, 12:56:37 PM »
Interesting Thanks..
Lets make the world a better place

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal