alex123
asked on
Using g77 to compile Fortran library on 64bit system
Hello,
I've encountered a problem compiling a library written in Fortran and C on a 64bit system. I've tested the library on a 32bit system and it is running fine, so the problem must be with how I compile it on a 64bit system, details: gcc 3.4.5 Suse 9.
The flags used to compile on 32 bit system are:
LARGE_FILE = -Dlinux -DFOPEN64
DEBUG =
#gcc flags
CFLAGS = $(DEBUG) -DREAL_8 -DTABLE_PATH=\"emos\" $(LOCAL_CFLAGS) $(LARGE_FILE)
#g77 flags
FFLAGS = $(DEBUG) -fno-second-underscore -Dlinux -DUSE_NO_POINTERS -DREAL_8 -DREAL_BIGGER_THAN_INTEGER -DTABLE_PATH=\"emos\"
I have modified it for 64bit compilation by adding
-m64 to both CFLAGS and FFLAGS, the library still compiles but calls to some of its functions result in Segmentation fault.
After some playing around I discovered that adding an additional optimization flag -O3 solves some of the problems, that is some functions begin to work but eventually the thing still crashes.
If anyone can provide a proper procedure to compile under 64bit system that would help a lot.
Thank you!
Alex
I've encountered a problem compiling a library written in Fortran and C on a 64bit system. I've tested the library on a 32bit system and it is running fine, so the problem must be with how I compile it on a 64bit system, details: gcc 3.4.5 Suse 9.
The flags used to compile on 32 bit system are:
LARGE_FILE = -Dlinux -DFOPEN64
DEBUG =
#gcc flags
CFLAGS = $(DEBUG) -DREAL_8 -DTABLE_PATH=\"emos\" $(LOCAL_CFLAGS) $(LARGE_FILE)
#g77 flags
FFLAGS = $(DEBUG) -fno-second-underscore -Dlinux -DUSE_NO_POINTERS -DREAL_8 -DREAL_BIGGER_THAN_INTEGER
I have modified it for 64bit compilation by adding
-m64 to both CFLAGS and FFLAGS, the library still compiles but calls to some of its functions result in Segmentation fault.
After some playing around I discovered that adding an additional optimization flag -O3 solves some of the problems, that is some functions begin to work but eventually the thing still crashes.
If anyone can provide a proper procedure to compile under 64bit system that would help a lot.
Thank you!
Alex
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
>It there any way to force g77 to compile the library with INTEGER=INTEGER*8 instead of INTEGER*4?
I don't see any option for that!
You may be able to do it by adding IMPLICIT INTEGER * 8 ( I-N ) everywhere.
I don't see any option for that!
You may be able to do it by adding IMPLICIT INTEGER * 8 ( I-N ) everywhere.
ASKER
I have a followup question to the original one. It seems that even on a 64bit system fortran's INTEGER type remains INTEGER*4 and not INTEGER*8. The library I am compiling might be suffering from this since it intefraces with some C code of its own and because of this the types passed between C and Fortran code no longer match. For my purposes I would also prefer to have all INTEGER types be equivalent to INTEGER*8. It there any way to force g77 to compile the library with INTEGER=INTEGER*8 instead of INTEGER*4?
Thank you