I am getting the following error while trying to compile a Fortran program with gfortran and FFTW3 library. The program however compiles successfully with the Intel compiler ifort.
Error
Undefined symbols for architecture x86_64:
"__gfortran_os_error_at", referenced from:
_MAIN__ in ccAVlghr.o
ld: symbol(s) not found for architecture x86_64
Compile Command
gfortran -I/usr/local/include -L/usr/local/lib pois.f90 -lfftw3 -lm
pois.f90 is the program which contains FFTW3 commands to solve a Poisson equation through Fourier transform.
The equivalent C program also compiles and executes successfully. The FFTW3 statements are inserted in Poisson.f90 as per FFTW3 documents. The routine which uses FFTW3 commands is given below
subroutine fft_forward(j,f,Fr,Fi)
use, intrinsic :: iso_c_binding
implicit none
include 'fftw3.f03'
double precision :: f(j),Fr(j),Fi(j)
integer :: i,j
type(C_PTR) :: plan
complex(C_DOUBLE_COMPLEX) :: FF(j)
plan = fftw_plan_dft_r2c_1d(j,f,FF,FFTW_ESTIMATE)
call fftw_execute_dft_r2c(plan,f,FF)
call fftw_destroy_plan(plan)
do i = 1,j
Fr(i) = real(FF(i))/j
Fi(i) = aimag(FF(i))/j
enddo
Fr = Fr/j; Fi = Fi/j
end
I also tried using a compiler flag -lgfortran but got the same error. Any suggestion will be of great help.
It probably depends on what you did while installing
GNU Fortran,FFTW, et al.In my case, it works as expected.
I have
GNU Fortraninstalled from sources: gcc-9-2-0Then, I have built
FFTWusing my own installation ofGNU Fortranand then, I have compiled your sample using
I have also added short
_mainstuff like so to double check it links with the stuffafter building, it runs as expected
I guess you have sort of a messy
GNU Fortran+FFTWinstallation.