I have a fortran dll/so which needs to know its own programhandle.
On windows, I can obtain the handle from the DLLMain routine:
integer(4) function DllMain(hInst, ul_reason_being_called, lpReserved)
!DEC$ ATTRIBUTES STDCALL, ALIAS : 'DllMain' :: DllMain
integer(8) hInst, ul_reason_being_called, lpReserved, program_handle
program_handle = hInst
DllMain = 1
end
But as far as I understand, the DLLMain function is only called on windows. How can I obtain the handle on linux?
The dll opens a child dll that needs to call a method in the parent dll. For this purpose I need the handle of the parent dll: getprocaddress(parent_dll_handle, 'method_name')
dlopenreturns? How do you open the library?dlopen()?) and what you want to do with it (that you can't by simply passing a suitable function pointer as argument).RTLD_NEXTwork?