1

Basis

I have installed FFTW in my system manually by using ./configure, make commands the procedure mentioned in the website using some flags.

I do thus have fftw3.h header file as can be seen below

locate fftw3.h
/home/anirbankopty/Softwares/FFTW/fftw-3.3.10/api/fftw3.h
/home/anirbankopty/Softwares/FFTW/fftw-install/include/fftw3.h

Problem

But, still, when compiling my C code using the -lfftw3 flag, it says

gcc FFT_denoise.c -lfftw3 -lm
FFT_denoise.c:5:10: fatal error: fftw3.h: No such file or directory
    5 | #include <fftw3.h>
      |          ^~~~~~~~~
compilation terminated.

I tried doing in Fortran and also there I am getting

gfortran FFT_denoise.f03 -lfftw3 -lm
/usr/bin/ld: cannot find -lfftw3
collect2: error: ld returned 1 exit status

Tried

I Tried adding those fftw3.h path i.e. /home/anirbankopty/Softwares/FFTW/fftw-install/include/ to the PATH variable, but still the problem persists.

I use zsh shell.

akopty
  • 15
  • 1
  • 6
  • Does this answer your question? [Where does gcc look for C and C++ header files?](https://stackoverflow.com/questions/344317/where-does-gcc-look-for-c-and-c-header-files) – veryreverie Feb 06 '22 at 09:34

1 Answers1

2

The path to included files belongs in the -I argument to the compiler, not in PATH:

gcc -I/home/anirbankopty/Softwares/FFTW/fftw-install/include/ FFT_denoise.c -lfftw3 -lm

Similarly the path to library files belongs in the -L argument. This will probably the next issue you will face.

user17732522
  • 53,019
  • 2
  • 56
  • 105
  • Thanks, so that means that the compiler doesn't look for files in the `$PATH` variables (defined for the terminal). We have to specify them explicitly for the compiler. But I was wondering is there a way to add paths to the compiler default `-I` or `-L` sections, so that I don't have to write that big path all the time? – akopty Feb 06 '22 at 11:56
  • @akopty The compiler usually has defaults for this built-in, e.g. `/usr/include` and `/usr/lib`. These are also the paths where the system package manager usually installs files. So if you use the system package manager to install the libraries, you shouldn't need to specify any of the paths. One usually uses a build system, such as make or cmake instead of manually calling `gcc`, which also avoids spelling out path names all the time. – user17732522 Feb 06 '22 at 12:12