4

I am sure this is a simple issue, but I am having a rough time getting in done. I am using this code snippet from http://www.fftw.org/fftw2_doc/fftw_2.html. I have the library installed (via homebrew). The include folder (/usr/local/include) has

fftw3.f
fftw3.f03
fftw3.h
fftw3l.f03
fftw3q.f03

Here is the code snippet from the site. I have tried it with both fttw.h and fttw3.h

#include <fftw.h>

int main (int argc, char** argv){
 fftw_complex in[N], out[N];
 fftw_plan p;

 p = fftw_create_plan(N, FFTW_FORWARD, FFTW_ESTIMATE);

 fftw_one(p, in, out);

 fftw_destroy_plan(p);  

     return 0;
}

It keeps throwing

fftwtest.c:1:10: fatal error: 'fftw3.h' file not found
#include <fftw3.h>
     ^
1 error generated.
balazs630
  • 3,421
  • 29
  • 46
Red
  • 2,256
  • 5
  • 25
  • 38
  • 2
    Not this error, but the one you're going to have next: That code uses FFTW's old version 2 API, but you have the current (backwards incompatible) version installed. Read up on http://www.fftw.org/fftw3_doc – tab Nov 22 '13 at 07:16
  • If you just want to calculate FFTs on OS X then you already have the Accelerate framework available, i.e. you don't need to use FFTW unless you want your code to be cross-platform. – Paul R Nov 22 '13 at 08:41

3 Answers3

7

/usr/local/include and /usr/local/lib aren't on the default header search path anymore in Mavericks. You'll need to add them with -I and -L flags, respectively.

Carl Norum
  • 219,201
  • 40
  • 422
  • 469
3

I was finally able to install pyfftw via the following, all in one terminal session:

brew install fftw
export DYLD_LIBRARY_PATH=/usr/local/lib
export LDFLAGS="-L/usr/local/include"
export CFLAGS="-I/usr/local/include"
pip install pyfftw
David Ketcheson
  • 4,035
  • 2
  • 30
  • 25
  • This worked for me, with one small tweak: I had to use `export LDFLAGS="-L/usr/local/lib"` (with `/lib` instead of `/include`). – Chris Nolet Jul 01 '17 at 00:45
  • This worked for me to install the latest version of pyFFTW on macOS Mojave: `export LDFLAGS="-L/usr/local/lib"`, `export CFLAGS="-I/usr/local/include"`, `pip install git+git://github.com/pyFFTW/pyFFTW.git` – Steve Jan 21 '19 at 16:05
  • I had to do. export CFLAGS="-I/opt/homebrew/include -Wno-implicit-function-declaration" – user2555515 May 19 '23 at 20:04
1

You need the right compiler flags. Add /usr/local/include to your header search path. This is done with the -I flag for the compiler, or if you are using Xcode, you can set it in the project settings.

Dietrich Epp
  • 205,541
  • 37
  • 345
  • 415