2

I'm using gfortran from cygwin (x86_64) on windows 7 to compile some old fortran code from NASA. When I use

gfortran cma.f -o cma.exe

the code compiles and works but needs the following four libraries in the same folder to work: cyggcc_s-seh-1.dll, cyggfortran-3.dll, cygquadmath-0.dll, and cygwin1.dll

I'd like to have it run independently so I've tried

gfortran cma.f -static -o cma.exe

But then I get several "relocation truncated to fit: R_X86_64_PC32 against undefined symbol" errors:

/usr/lib/gcc/x86_64-pc-cygwin/4.9.3/libgfortran.a(write.o): In function `write_float':
/usr/src/debug/gcc-4.9.3-1/libgfortran/io/write_float.def:1300:(.text$write_float+0x15c): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `quadmath_snprintf'
/usr/lib/gcc/x86_64-pc-cygwin/4.9.3/libgfortran.a(write.o): In function `determine_en_precision':
/usr/src/debug/gcc-4.9.3-1/libgfortran/io/write_float.def:1213:(.text$write_float+0x7cf): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `quadmath_snprintf'
/usr/lib/gcc/x86_64-pc-cygwin/4.9.3/libgfortran.a(write.o): In function `write_float':
/usr/src/debug/gcc-4.9.3-1/libgfortran/io/write_float.def:1300:(.text$write_float+0x84e): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `quadmath_snprintf'
/usr/lib/gcc/x86_64-pc-cygwin/4.9.3/libgfortran.a(write.o): In function `output_float_FMT_G_16':
/usr/src/debug/gcc-4.9.3-1/libgfortran/io/write_float.def:1140:(.text$write_float+0xf22): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `quadmath_snprintf'
/usr/src/debug/gcc-4.9.3-1/libgfortran/io/write_float.def:1140:(.text$write_float+0x1781): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `quadmath_snprintf'
/usr/lib/gcc/x86_64-pc-cygwin/4.9.3/libgfortran.a(read.o): In function `_gfortrani_convert_real':
/usr/src/debug/gcc-4.9.3-1/libgfortran/io/read.c:175:(.text$_gfortrani_convert_real+0x72): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `strtoflt128'
/usr/lib/gcc/x86_64-pc-cygwin/4.9.3/libgfortran.a(read.o): In function `_gfortrani_convert_infnan':
/usr/src/debug/gcc-4.9.3-1/libgfortran/io/read.c:251:(.text$_gfortrani_convert_infnan+0x53): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `strtoflt128'
collect2: error: ld returned 1 exit status

I'm new to compiling from source, but I have done some programming (mostly in matlab/octave). I don't know Fortran and the code is 4418 lines long and does some complex thermodynamics. So tinkering with the code isn't a very good option for me.

Also I know it can be compiled in a 32 bit windows console app with MS Visual Studio using the Intel Fortran composer XE2013, Update 5, compiler with the following options: 132 column, 32 bit release version, and no runtime array bounds checking. But I don't have the Intel compiler.

So it should just be a matter of what compiler option to use for gfortran. I've tried a lot of different flags and none have done the trick so far. So how can I get the exe to run independently"?

There are some similar questions, however those solutions seem to involve how the code is written. I can't change the code so I need a solution involving how I compile the code.

francescalus
  • 30,576
  • 16
  • 61
  • 96
  • possible duplicate of [What does this GCC error "... relocation truncated to fit..." mean?](http://stackoverflow.com/questions/10486116/what-does-this-gcc-error-relocation-truncated-to-fit-mean) – Alexander Vogt Jul 29 '15 at 16:30
  • Do you have the static version of libquadmath installed? – Alexander Vogt Jul 29 '15 at 16:35
  • How do I tell if I have the static version of libquadmath installed? I have therse files instaled: libquadmath.a libquadmath.info.gz libquadmath.dll.a libquadmath0.lst.gz quadmath.h quadmath_weak.h – galaxyngc1672 Jul 29 '15 at 17:11
  • I've looked at [what-does this GCC...](http://stackoverflow.com/questions/10486116/what-does-this-gcc-error-relocation-truncated-to-fit-mean) and the link provided. The answer explains what is going on but not how to fix it if the code is good and the problem is with how its being compiled. It sugests "-mmodel" wich isn't recognized by the gfortran a similar "-mcmodel=large" doese not change the results. Also mentioned is "the movabs instruction" I have no idea what he's talking about and searching didn't turn up much. Maybe I'm missing something? I am pretty new to this i.e. Monday. – galaxyngc1672 Jul 29 '15 at 17:37
  • Is it possible to get access to the Intel compiler? Some codes (older ones especially, in my limited experience) make use of many compiler-specific functions and it *may* be difficult for you to change them all. If you know it compiles with Intel could you build it statically using Intel? Not that I think your current problem is necessarily related to compiler-specific functions. – Ross Jul 30 '15 at 00:34

1 Answers1

2

I think you have to drop "-static" in cygwin64. AFAIK, there is only shared library version of gfortran provided in cygwin64 packages.

Lywx
  • 395
  • 5
  • 10