0

I'm having some problem compiling the library hypoct with gcc.

The library is written in Fortran and, since I don't know anything of Fortran, I want to use the C wrapper bundled with the Fortran code. The library structure is the following:

src/hypoct.f90 --------------> Main code
src/hypoct_c.f90 ------------> Fortran part of the C wrapper
c/hypoct.c ------------------> C Part of the C wrapper
examples/hypoct_driver.c ----> Example that I want to compile

Now, during the Fortran code compilation there are no problems, I launch the following commands without errors or warnings:

gfortran -fPIC -Wall -O3  -Jbin -c src/hypoct.f90 -o bin/hypoct.o
gfortran -fPIC -Wall -O3  -Jbin -c src/hypoct_c.f90 -o bin/hypoct_c.o

But when the last command is launched:

gcc -o examples/hypoct_driver -fPIC -Wall -O3 -Ibin -Ic -lgfortran -lm examples/hypoct_driver.c bin/hypoct.o bin/hypoct_c.o

a very long list of errors, of this type, arise:

bin/hypoct.o: In function `__hypoct_MOD_hypoct_malloc2i':
hypoct.f90:(.text+0xa61): undefined reference to `_gfortran_runtime_error_at'
hypoct.f90:(.text+0xa6f): undefined reference to `_gfortran_runtime_error'
hypoct.f90:(.text+0xa7b): undefined reference to `_gfortran_os_error'
hypoct.f90:(.text+0xa97): undefined reference to `_gfortran_runtime_error_at'

BUT, if I change gcc to gfortran in the last command everything goes ok, without errors (but I really want to use gcc in the last command).

I'm struggling on this by a couple of days, any help is really appreciated.

Fortytwo
  • 29
  • 2

0 Answers0