0

I'm trying to run a simple code that includes the fftw library. I know the code is right as it is provided as a test code by the authors. This is what I typed during compilation:

gcc my file.c  -L/home/ankit/Desktop/fftw-3.3.6-pl2/lib/ 
-I/home/ankit/Desktop/fftw-3.3.6-pl2/include/  -lfftw  -lm

I get the errors:

myfile.c: (.Text+0x2c):. undefined reference to 'fftw_plan_dft_2d' collect2: ld returned 1 exit status

jAC
  • 5,195
  • 6
  • 40
  • 55
PooriR
  • 43
  • 6
  • 1
    where is your code? Does the code `#include` the necessary header file for the fftw library? Have you looked carefully at your compile/line statement? Do you notice the space in the middle of the file name? – user3629249 Jun 17 '17 at 00:41
  • On my computer, the name of the fftw library in .../lib is `libfftw3.a`. Consequently, I link it as `-lfftw3`. Could you test it? See also http://www.fftw.org/fftw3_doc/Linking-and-Initializing-MPI-FFTW.html and https://stackoverflow.com/questions/25568027/unable-to-link-to-fftw3-library – francis Jun 17 '17 at 07:58
  • My code is exactly the same as the one used in https://stackoverflow.com/questions/25568027/unable-to-link-to-fftw3-library, and my problem was exactly the same as what he had too. I tried the suggestions but they didn't work. The version of fftw I'm using is different, it's fftw-3.3.6-pl2 which I renamed as fftw3 as I thought it might help. – PooriR Jun 17 '17 at 12:52
  • The my file was just for example, my code is actually named del.c, so there is no space in it. I tried fftw3 but, unlike fftw, it does not get recognised, or pass compilation when I include only fftw_complex and remove the other fftw functions. – PooriR Jun 17 '17 at 13:10

1 Answers1

0

It wasn't a linking problem, installation was faulty and I had to use 'sudo make install' to get the permission for the installation to be successful. I could link it with 'gcc test.c -lfftw3 -lm' after. Thanks for your suggestions!

PooriR
  • 43
  • 6