- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am porting legacy code from a Sun with mixed Fortran and C. I am trying
to exchange data between a Fortran common block and a C struct( VC++ 6.0). I keep
getting linker error mesages like:
error LNK2001: unresolved external symbol _COM1
I have read the help files and set up a test case that follows their guidelines.
(See below). This test case works. I am sure I have set up the common blocks and structs exactly
like this example but I keep getting the error messages when I try to link
my code which . Any suggestions as to why my code won't link even though it is structured
like the following example?
The C modules are C, not C++. The Fortran is a quickwin project.
Jim Breeding
In Fortran source (tstcom.h):
to exchange data between a Fortran common block and a C struct( VC++ 6.0). I keep
getting linker error mesages like:
error LNK2001: unresolved external symbol _COM1
I have read the help files and set up a test case that follows their guidelines.
(See below). This test case works. I am sure I have set up the common blocks and structs exactly
like this example but I keep getting the error messages when I try to link
my code which . Any suggestions as to why my code won't link even though it is structured
like the following example?
The C modules are C, not C++. The Fortran is a quickwin project.
Jim Breeding
In Fortran source (tstcom.h):
PROGRAM TSTCOM
IMPLICIT NONE
INTERFACE
SUBROUTINE c_module
!DEC$ ATTRIBUTES C :: c_module
END SUBROUTINE c_module
END INTERFACE
REAL A,B
INTEGER N1,N2,I
CHARACTER CARRAY*8,SETCOM(0:7)
COMMON /COM1/A,B,N1,N2,SETCOM
call c_module
END
In C Header (tstcom.h)
#pragma pack(2)
extern struct dum {
float a;
float b;
int n1;
int n2;
char setcom[8];
};
#pragma pack()
In C source (c_module.c)
#include
#include "tstcom.h"
void c_module()
{ float aa,bb;
int nn1,nn2;
char setcom2[8];
extern struct dum COM1;
aa = COM1.a;
bb = COM1.b;
nn1 = COM1.n1;
nn2 = COM1.n2;
strcpy(COM1.setcom,"ijklmnop");
}
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It would be helpful to see a test case that doesn't work...
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