0

I have a very simple question regarding the use of external library in Qt, and in particular FFTW. I am working on a project in whice I need to build a GUI. I am working with Qt creator for the first time and am a pretty novice porgrammer.

I need to preform fft in my program and I have found that FFTW library is very useful for that matter. How I can make use of the library in Qt? I know It porbably have nothing to do with the program and more with the C++ language and compiling and linking, but I am basicly in the dark on this subject.

I failed to find a detailed enough answer and can make progress on my project without the use of this library. please help.

Daniels
  • 1
  • 1
  • 2
  • Yes I have encountered this question but non of the answers have helped me! that is why I asked again in order to wishfully get a detailed enough answer! – Daniels Jul 23 '15 at 00:03

1 Answers1

1

When you want to use an external library in c/c++ first of all you will have to find one ore more *.h files that should have been shipped with the library, .h files describe to the compiler what will be found inside the library. You will have to #include the correct .h file in your code and tell the compiler where to find it (in which folder).

in your case you should have a line at the top of your program

#include <fftw3.h>

Adding this linr in you .pro file will help the compiler finding where your .h file is.

INCLUDEPATH += "C:/fftwMinGW"

Then you will have to specify to the compiler where the library can be found and what's its name. You do that by adding a line into you .pro file (the project file) that you find at the top of thr tree of your project on the left side in Qt creator.

The line to add to the pro file is the following. LIBS''= -lfftw3

Marco
  • 1,952
  • 1
  • 17
  • 23
  • Thank you for your response. I did include fftw3.h at the top. As you suggested I added to the .pro file the commands: INCLUDEPATH += "C:/fftwMinGW" (with the path in which the library is.) and LIBS''= -lfftw3. Sadly when I run my code I get an error: "cannot find -lfftw3". What should I do ? – Daniels Jul 21 '15 at 22:46
  • 1
    You would also need to add a switch to LIBS to tell it where to find the fftw3 library for linking. Something like `LIBS = -LC:/fffwMingW -lfftw3` – Hamish Moffatt Jul 22 '15 at 01:16
  • Here is my current .pro file : http://i.imgur.com/u7iXMu2.png I still get the same error. What am I doing wrong? thank you for your help. – Daniels Jul 22 '15 at 10:40
  • in C:\User\Desktop\... you actually have a file called fftw3.a ? maybe you a \lib folder in there – Marco Jul 22 '15 at 13:21
  • In that folder I have all the files in the download found here: http://www.fftw.org/install/windows.html (32-bit version). I don't see there any file called fftw3.a .. – Daniels Jul 22 '15 at 13:29
  • Do you have any ffwt3.lib in that folder or libfftw3-4.lib ? – Marco Jul 22 '15 at 16:01
  • Here are the files I do have: http://i.imgur.com/pTCQ52G.png No .lib files... There are some dll files and the header file, in addition to some .f03 , .f , .def files which I know nothing about. – Daniels Jul 22 '15 at 16:38
  • you can download ftp://ftp.fftw.org/pub/fftw/fftw3win32mingw.zip or build fftw... – hassan deldar Oct 30 '15 at 06:25