sushiman
sushiman

Reputation: 13

FFTW: Undefined reference to fftw_mpi_init

I am using MPI to run FFTW but it triggers undefined reference error as below when compiling the program with -lfftw3f_mpi -lfftw3f -lm.

function main: error: undefined reference to 'fftw_mpi_init'
function main: error: undefined reference to 'fftw_destroy_plan'

But if modifying with -lfftw3_mpi -lfftw3 -lm that uses double type as default, it successfully gets compiled.

Does anyone know why?

Upvotes: 1

Views: 2654

Answers (1)

Hristo Iliev
Hristo Iliev

Reputation: 74395

Because the corresponding functions are called fftwf_mpi_init and fftwf_destroy_plan. Extract from the documentation that can be found here:

  • Link to the single/long-double libraries; on Unix, -lfftw3f or -lfftw3l instead of (or in addition to) -lfftw3. (You can link to the different-precision libraries simultaneously.)
  • Include the same <fftw3.h> header file.
  • Replace all lowercase instances of fftw_ with fftwf_ or fftwl_ for single or long-double precision, respectively. (fftw_complex becomes fftwf_complex, fftw_execute becomes fftwf_execute, etcetera.)
  • Uppercase names, i.e. names beginning with FFTW_, remain the same.
  • Replace double with float or long double for subroutine parameters.

Upvotes: 2

Related Questions