- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am trying to explicitly load a dll within a main program.
LoadLibrary works fine.
GetProcAddress allows me to access exported subroutines in my dll.
However, it cannot use this function to access common blocks, although I have exported them.
Win32 documentation on the function suggests it is designed to access functions as well as variables.
Does anybody have a suggestion ?
Andy
PS. I want to avoid having to link with my dll's lib file - i.e. I need to load the dll explicitly
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have got the address now (a lower/upper case stupid problem), but the content of the common (a real*8 variable) is not shared. Any ideas ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Where you build the DLL, add the following to the Linker "additional options:
/section:.data,RWS
This is required when you want to read-write share a COMMON with a DLL.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Steve,
Thank you for the suggestion. I still can't make it work.
In my main program, I have declared
real*8 mainvar
common/maincommon[dllexport]/ mainvar
mainvar = -1.D0
I then call an initialization function of my dll, in which I wish to make maincommon shared
real*8 mainvar
common/maincommon/ mainvar
integer hExe
integer*4 pcommon
hExe = LoadLibrary("main.exe") ! Open the main program
pcomm = GetProcAddress(hExe, "maincommon")
I would like to see mainvar = -1.D0, yet it is always 0.D0 even with the linker option
Thanks for any help !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oh, I see. You can't do it that way and I should have spotted that earlier. To reference the COMMON from the DLL you will have to do it as if it were an external variable, not a COMMON in the main program. So instead of:
common /maincommon/ mainvar
use:
pointer (pcommon, mainvar)
You should also remove the declaration of pcommon (let the POINTER statement declare it) and use the name pcommonand not pcomm in the assignment from GetProcAddress.
The only way to share COMMONs with a DLL and still use it as a COMMON is to link to an export library.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page