DLL: AttachProcess() will not be called

Post bugreports for the Linux version here
User avatar
Sicro
Enthusiast
Enthusiast
Posts: 538
Joined: Wed Jun 25, 2014 5:25 pm
Location: Germany
Contact:

DLL: AttachProcess() will not be called

Post by Sicro »

DLL:

Code: Select all

Global Text.s = "Nothing was called!"

ProcedureDLL AttachProcess(Instance) ; ProcedureCDLL doesn't work, too.
  Text = "AttachProcess was called!"
EndProcedure

ProcedureDLL.s GetText()
  ProcedureReturn Text
EndProcedure
Program:

Code: Select all

If OpenLibrary(0, "/tmp/bla.so")
  Debug PeekS(CallFunction(0, "GetText"))
  CloseLibrary(0)
EndIf
Fred wrote:AttachProcess() should be called on linux as well, if not it's a bug.
Source: http://www.purebasic.fr/english/viewtop ... 33#p485833
Image
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
Taz
User
User
Posts: 52
Joined: Sat Jan 20, 2018 5:28 pm
Location: Germany

Re: DLL: AttachProcess() will not be called

Post by Taz »

if you do it like this, it works:

Code: Select all

Global Text.s

ProcedureDLL AttachProcess(Instance)
  Text = "AttachProcess was called!"
EndProcedure

ProcedureDLL.s GetText()
  ProcedureReturn Text
EndProcedure
OS:

Code: Select all

Kernel       : Linux 4.13.0-21-generic (x86_64)
Version      : #24-Ubuntu SMP Mon Dec 18 17:29:16 UTC 2017
C-Library    : GNU C Library / (Ubuntu GLIBC 2.26-0ubuntu2) 2.26
Distribution : Ubuntu 17.10
Computername : Lubuntu
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: DLL: AttachProcess() will not be called

Post by mk-soft »

Is different to windows...

At windows, the PB-compiler call first the procedures and AttachProzess

Code: Select all

EnableExplicit

DeclareModule Common
  Global Text.s
EndDeclareModule

Module Common
  
  ; Do this always inside Procedure for DLL's
  Procedure InitModule()
    Text + "Init... "
  EndProcedure : InitModule()
  
EndModule

UseModule Common

ProcedureDLL AttachProcess(Instance) ; ProcedureCDLL doesn't work, too.
  Text + "AttachProcess was called!... "
EndProcedure

ProcedureDLL.s GetText()
  ProcedureReturn Text
EndProcedure

CompilerIf #PB_Compiler_Debugger
  If OpenLibrary(0, "bla.so")
    Debug PeekS(CallFunction(0, "GetText"))
    CloseLibrary(0)
  EndIf
CompilerEndIf
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply