- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have a difficulty in Mixed language programming. There are many global variables in a fortran module, which have to be accessed from C++ main program. The compiler is giving no errors with the following simple structure, but, linker gives error - 'undefined reference to the common variable in C++ object code'.
fortran module:
MODULE EXAMP
SAVE
REAL, X(4), Y(4), Z(4)
REAL, PARAMETER :: Pi =3.14159
END MODULE EXAMP
C++:
#include
extern "C" float EXAMP_mp_X[4];
extern "C" float EXAMP_mp_Y[4];
extern "C" float EXAMP_mp_Z[4];
extern "C" float EXAMP_mp_Pi;
using namespace std;
int main()
{
.....
....
}
I am using Linux...g++ and gfortran compiler in the following way
gfortran -c mod.f
g++ -c testc.cpp
g++ -o test mod.o testc.o -llapack
Could anyone please share their experience in handling the similar problem. Thanking you,
I have a difficulty in Mixed language programming. There are many global variables in a fortran module, which have to be accessed from C++ main program. The compiler is giving no errors with the following simple structure, but, linker gives error - 'undefined reference to the common variable in C++ object code'.
fortran module:
MODULE EXAMP
SAVE
REAL, X(4), Y(4), Z(4)
REAL, PARAMETER :: Pi =3.14159
END MODULE EXAMP
C++:
#include
extern "C" float EXAMP_mp_X[4];
extern "C" float EXAMP_mp_Y[4];
extern "C" float EXAMP_mp_Z[4];
extern "C" float EXAMP_mp_Pi;
using namespace std;
int main()
{
.....
....
}
I am using Linux...g++ and gfortran compiler in the following way
gfortran -c mod.f
g++ -c testc.cpp
g++ -o test mod.o testc.o -llapack
Could anyone please share their experience in handling the similar problem. Thanking you,
Link Copied
0 Replies
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