- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to create a Fortran DLL containing a Common Block which I can then use to link with a C program to resolve an external name.
The DLL appears to create successfully but when I link the C program I always get an unresolved external symbol. This code does work when the Fortran part is not built as a DLL. Does anybody have any ideas ?
I have shown my code below.
Fortran DLL:
!DEC$ DEFINE GLOBAL_EXPORT
block data
include 'GLOBAL01.FI'
data PRBUZ /0.0/
end
GLOBAL01.FI include file:
REAL*8 prbuz
COMMON /GLOBAL01/ prbuz
!DEC$ IF DEFINED (GLOBAL_EXPORT)
!DEC$ ATTRIBUTES DLLEXPORT :: /GLOBAL01/
!DEC$ ELSE
!DEC$ ATTRIBUTES DLLIMPORT :: /GLOBAL01/
volatile /GLOBAL01/
!DEC$ ENDIF
C program:
#include
struct g1 struct
{
double prbuz;
};
extern struct g1 global01;
main()
{
global01.prbuz = 50.0;
}
When this is linked against the above DLL I always get GLOBAL01 reported as undefined.
The DLL appears to create successfully but when I link the C program I always get an unresolved external symbol. This code does work when the Fortran part is not built as a DLL. Does anybody have any ideas ?
I have shown my code below.
Fortran DLL:
!DEC$ DEFINE GLOBAL_EXPORT
block data
include 'GLOBAL01.FI'
data PRBUZ /0.0/
end
GLOBAL01.FI include file:
REAL*8 prbuz
COMMON /GLOBAL01/ prbuz
!DEC$ IF DEFINED (GLOBAL_EXPORT)
!DEC$ ATTRIBUTES DLLEXPORT :: /GLOBAL01/
!DEC$ ELSE
!DEC$ ATTRIBUTES DLLIMPORT :: /GLOBAL01/
volatile /GLOBAL01/
!DEC$ ENDIF
C program:
#include
struct g1 struct
{
double prbuz;
};
extern struct g1 global01;
main()
{
global01.prbuz = 50.0;
}
When this is linked against the above DLL I always get GLOBAL01 reported as undefined.
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Actually, I'd bet that you get _global01 undefined. C is case-sensitive - change the name to GLOBAL01 in the C code and this should work, though I think you also need a _dllimport pragma in there somewhere...
Steve
Steve

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