This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

g77: common block with C mixed code


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 has:

SUBROUTINE QL0001(....)
..
..
REAL  EPS
COMMON /CMACHE/EPS
...
..
END

in C code I  need to access EPS and assign a value to it before
calling QL0001

the C code main_t.c has:
....
/*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 compilation is as:
STEP 1)

g77 -shared -fPIC -ff77 -w -fno-underscoring -O3 -malign-double
-ffast-math -funroll-all-loops \ -fno-f2c -Bdynamic -mcpu=pentium
-fno-exceptions  qld.f  -o qld.dll \
-Wl,--dll,--output-def,qld_out.def,--out-implib,libqld.lib

STEP 2)

gcc -o main_t.exe main_t.c -L./ -lqldx

linking is successful and I do get a main_t.exe.

but...
in all the three attempts I tried above,  main_t.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 for final release.

Is there any way this problem can be sorted out ?

apologies if I have missed something above

many thanks

mangesh



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]