User forums > Help

Installing the FFTW3 library on Windows 10 using Code::Blocks (C++)

<< < (2/3) > >>

Miguel Gimenez:
In the compiler search dialog you have the FTW3 folder twice, one absolue and one relative:


--- Code: ---"C:\Program Files (x86)\CodeBlocks\myLibraries\FFTW3"
"..\..\..\..\..\..\..\Program Files (x86)\CodeBlocks\myLibraries\FFTW3"

--- End code ---

In the linker search path you have only the relative version. Both versions have spaces, this sometimes confuses the tools. Try copying the dll to another folder (p.e. c:\temp) and update the linker search path.

Angelos_Fra:

--- Quote from: Miguel Gimenez on July 09, 2020, 12:00:04 pm ---In the compiler search dialog you have the FTW3 folder twice, one absolue and one relative:

--- End quote ---

And should I have them both as absolute and relative paths?



--- Quote from: Miguel Gimenez on July 09, 2020, 12:00:04 pm ---In the linker search path you have only the relative version. Both versions have spaces, this sometimes confuses the tools. Try copying the dll to another folder (p.e. c:\temp) and update the linker search path.

--- End quote ---

Should I only have it as relative path?

EDIT: I copied the DLL in another folder whose directory does not have any blanks and tried with both relative and absoulte paths. It says "no such file or directory". It won't compile.

gd_on:

--- Code: ---For windows, I have read that I only need the .lib file.
--- End code ---
No.
This is true if you use the visual studio compiler (Microsoft) and if you want to use with it a static library.
For MinGW compiler, the dll is sufficient for a dynamic linking (64 bits in your case). If you want to link statically, you need a static library with the .a extension.
A .lib library may work with MinGW, but I don't think it's recommended.

Miguel Gimenez:
I have just created a test project. The linker search path is not enough, you must put the absolute path of the DLL in Project -> Buld options -> Linker settings -> Other linker options.

In my case I put G:\Librerias81\fftw-3.3.5\libfftw3-3.dll and it compiles OK. You can also define a global variable and write $(#fftw.lib)\libfftw3-3.dll


--- Code: ---#include <stdio.h>
#include <stdlib.h>

#include <fftw3.h>

int main()
  {
  int N = 100;
  fftw_complex *in;
  in = (fftw_complex *)fftw_malloc(sizeof(fftw_complex) * N);
  fftw_free(in);
  return 0;
  }

--- End code ---

Angelos_Fra:
I am reporting below what I have done and it finally worked. The following instructions are based in the guide that can be found at https://www.learncpp.com/cpp-tutorial/a1-static-and-dynamic-libraries/.

1 ) Download the precompiled library .zip found in http://www.fftw.org/install/windows.html
2 ) Unzip into a new folder named "FFTW3" and place it wherever you like, for example C://myLibraries//FFTW3.
3 ) Copy the libfftw3-3.def file and paste it inside the "bin" folder that can be found inside the folder where your compiler is. For example, in my case C:\Users\User\Downloads\minGW_GCC_10_1\mingw64\bin
4 ) Put the directory of step 3 to system PATH. You can easily find instructions on web, especialy for windows 10.
5 ) Open the command window and change your directory to the one in step 3. Then execute:
--- Code: ---dlltool -v -d libfftw3-3.def -l libfftw3-3.a
--- End code ---

6 ) Now you can delete the libfftw3-3.def file from the compiler's bin directory and cut the libfftw3-3.a file that was created in there and paste it inside the directory in step 2. I created a folder named "Lib" so, in my case, the directory is C://myLibraries//FFTW3//Lib.
7 ) Open Code::Blocks and go to settings -> compiler -> Search directories ->compiler Tab and add the directory of step 2, namely the location where the header file .h is located.
8 ) Go to Settings -> Compiler -> Search directories -> Linker and add the directory where the .a file is located (see step 6).
9 ) Go to Project -> Build options -> Search directories -> Compiler and add the directory of step 2.
10 ) Go to Project -> Build options -> Search directories -> Linker and add the directory of step 6.
11 ) Go to Project -> Build options -> Linker settings and add the file .a (you have to literally select the file .a, not the folder where it can be found).
12 ) Copy the libfftw3-3.dll that can be found inside the FFTW3 folder and paste it inside the folder where the main.cpp is.

Now the following test code should be working fine.


--- Code: ---#include <fftw3.h>
int main()
  {
  int N = 100;
  fftw_complex *in;
  in = (fftw_complex *)fftw_malloc(sizeof(fftw_complex) * N);
  fftw_free(in);
  return 0;
  }


--- End code ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version