- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm trying to create a dll witha common block to share data between two or more programs. I'm following the directions under the help topic "Coding Requirements for Sharing Data in DLLS".
I created a small test-bed to try out my methodology. I created a dll with just this in one file:
BLOCK DATA T01
!DEC$ ATTRIBUTES DLLEXPORT :: /GLB1/
COMMON/GLB1/GL01,GL02,GL03
real gl01,gl02,gl03
end
Then I use this include file in two different programs in order to link with the dll created by above
!DEC$ ATTRIBUTES DLLIMPORT :: /GLB1/
COMMON/GLB1/GL01,GL02,GL03
real gl01,gl02,gl03
I include the .lib file in the linker input to these two programs and both programs link and run. The first program runs and sets GL03 then SLEEP() for several minutes. When I start the second program after the first one has gone to SLEEP(), it only sees values of 0.000 for GL03. It should load the same dll and access the same COMMON block so that it retrieves the value set by program1, but it doesn't seem to be sharing the same memory in the DLL.
Other than specifying the dll's 'lib' file as a dependancy, all other settings are the defaults for a console application (Visual Studio 2008 and Intel Fortran 11.1.048)
With previous versions I would edit the COFF objfile with link /section:.data=.GLB1,SRW in order to get this shared between processes, but the new compiler creates obj files without a .data section.
Any help would be appreciated.
Mike
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You will need to add data initialization of at least one variable in the COMMON to get a .data section.
There is a complete example of doing this provided with the product under DLL > DLL_Shared_Data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The sample you mentioned only shares/exports a couple variables. I'm trying to do a large number that are defined in a COMMON.
I had an initialization of one variable, but I was setting it to zero. I changed it to 1 and now have a data section.
I got it working, but there is some wierdness when I try to do a second common block. Have to DLLIMPORT them all on one line and can't use separate !DEC$ DLLIMPORT statements for each COMMON.
But all in one statement can work for me. Just some programs will be importing COMMONs that it doesn't use.
Thanks for your help,
Mike

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