g77 commo block with mixed code
Mangesh M Kale
M.Kale@soton.ac.uk
Fri Jan 24 15:54:00 GMT 2003
I am using some fortran routines as libraries (as dlls) in my main c
programme.
the set up is as: winXP+minGw + gcc g77 3.2.1
fortran file qld.f:
SUBROUTINE QL0001(....)
..
..
REAL EPS
COMMON /CMACHE/EPS
...
..
END
in my C code I need to access EPS and assign a value to it before
calling QL0001
the C code is main_t.c
....
/*extern struct
{ double eps; try1
} cmache;*/
/*extern double *cmache; */ try2
extern double cmache; // try3
__declspec(dllimport) void ql0001(....);
main()
{
....
/*cmache.eps=2.2204e-16;
*cmache =2.2204e-16; */
cmache =2.2204e-16;
....
ql0001(....).;
}
the copilation is as:
g77 -shared -fPIC -ff77 -w -fno-underscoring -O3 -malign-double
-ffast-math -funroll-all-loops \ -fno-f2c -Bdynamic -mcpu=pentium
-fno-exceptions qldx.f -o qldx.dll \
-Wl,--dll,--output-def,qldx_out.def,--out-implib,libqldx.lib
gcc -o main_t.exe main_t.c -L./ -lqldx
linking is successful and I do get a main_t.exe.
...
in all the three attempts I tried above, my main.exe is getting
terminated when eps variable is assigned.
the call to ql0001 is working fine as I have tested it without eps
assignment and handcoding it in fortran code. but I need to do it in C
code .
is there any way this problem can be sorted out ?
apologies if I have missed something above
many thanks
mangesh
More information about the Binutils
mailing list