Issue with using fftpack in MacOS 11.7

Hello,
I’m trying to use the double precision fftpack routines in a simple program of mine. I have built the fftpack package with fpm with no problems, and the compiler seems to find the needed module and object files (I provide the right include path to the compiler to find those).

Even though the program compiles with no issue, when trying to execute my program I get the following error. The main program seems unable to find the functions I include from fftpack. I’m working on MacOS 11.7 (BigSur) using gfortran 12.2.

Undefined symbols for architecture x86_64:
  "_dfftf_", referenced from:
      _MAIN__ in cckgQ0YM.o
  "_dffti_", referenced from:
      _MAIN__ in cckgQ0YM.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status

The program I’m trying to execute is the following.

program main
	use, intrinsic :: iso_fortran_env, only: real64
	use fftpack, only: dffti, dfftf

	implicit none
	integer, parameter :: rk = real64
	integer, parameter :: n = 8
	integer, parameter :: nsave = 2*n+15
	real(rk), parameter :: pi = 4*atan(1.0_rk)

	integer :: i
	real(rk), dimension(n) :: xvec
	real(rk), dimension(nsave) :: wsave

	do  i = 1, n
		xvec(i) = cos(2*pi*(i-1)/n)
	end do

	call dffti(n, wsave)
	call dfftf(n, xvec, wsave)
end program

I use fpm to pull fftpack and run your sample code, and everything is fine.
I’m using Windows OS, and I think there is nothing wrong with your sample code, maybe there is something wrong with the link library you built, or is it the specificity of macOS?

1 Like

Thank you for the prompt reply @zoziha. I solved the issue. It looks like I was providing the wrong library path to the compiler; the code runs properly now.

Thank you for trying out the sample program yourself though, it helped knowing that there was nothing wrong with it.