Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Sharing data via a module in a DLL

Ilie__Daniel
Beginner
1,070 Views

Hello!

The attached solution contains a module with two variables that are exported from a DLL and the main program, which should access these variables.

I cannot get the main program to build. I am probably doing something silly. Any help is greatly appreciated.

Daniel.

0 Kudos
4 Replies
DavidWhite
Valued Contributor II
1,070 Views
Daniel,

I beleive you misunderstand what DLLEXPORT does - this provides an entry point in the DLL for a routine to be accessed by the calling program. You cannot EXPORT a variable in this way.

Why do you want the Module in a DLL? You can build the app simply with the Module code in the main build.

David
0 Kudos
IanH
Honored Contributor III
1,070 Views
What error message do you get/compiler version are you using/steps are you taking? Your example builds here...

I'm pretty sure DLLEXPORT on variables is "ok". As an operating system concept it is definitely supported (though perhaps discouraged - consider get/set procedures instead), and tests show it works with the compiler too.
0 Kudos
Steven_L_Intel1
Employee
1,070 Views
DLLEXPORTing variables is fine. There is a worked example of doing exactly this in the sample DLL\DLL_Shared_Data installed with the compiler (unzip DLL.zip into a writable folder to use.) If it's a module variable, even better, as that will automatically turn into a DLLIMPORT. If you are sharing data between processes, you also need to set the data image section to RWS. See the sample for details.
0 Kudos
Ilie__Daniel
Beginner
1,070 Views
Thank you all for your suggestions.

Steve,
I found the sample and adapted my code. The whole solution builds fine but I still cannot get my program to work properly.

The solution consists of two executables and one DLL. The "shared-data.exe" launches the "writer.exe", using RUNQQ. "writer.exe" updates the integer in the module. "shared-data.exe" prints the updated integer variable. The problem is that I cannot get past the RUNQQ statement: I get the following message from Windows:
writer.exe The application was unable to start correctly (0xc0000005).
The returned result from RUNQQ is 5.

I alsoget the following warning when I build the DLL:
LINK : warning LNK4092: shared writable section '.data' contains relocations; image may not run correctly
(DLL-BuildLog.htm is attached). But the output from DUMPBIN /HEADERS (dumpbin.txt) does not show any relocations for .data Section.

I have attached the source andthe builds.
I am running on Windows 7 64bit. IVF 9.1.039. VS2005

Any ideas?

0 Kudos
Reply