Mingw FFTW3 cannot find a library/header file

2019-07-20 10:58发布

问题:

I am on a Windows machine, and I am trying to get Mingw (with gcc/g++ 4.9.2) to recognize that I have a library installed.

The library is the fftw3 (fast fourier transform) library here :

http://www.fftw.org/install/windows.html

I downloaded the folder which has three important dlls and some other header files too

libfftw3-3.dll libfftw3l-3.dll libfftw3f-3.ll

But I'm at a loss as to what to do with them.

I have C++ code from another author that requires the library, and when I run

waf configure waf build

I get the error that "-libfftw3" is not found.

I have already put the directory where the dlls are into my Windows path, and this seems like such a simple problem but I can't figure out how to get the compiler to find the pre-compiled DLLs. (I also tried just having the gcc compiler do a default search without specifying a library but it said "fftw.h" not found, which is strange because I already put that directory in my path.

Any help would be appreciated; I did read the website's instructions but for Windows it only tells you to use some commands for Visual Studio (but I'm not using that compiler) and I have browsed other sites for similar issues but I can't find a solution to this specific issue.

回答1:

You have to put both the header file(s), and the DLLs somewhere that GCC/G++ will look for them; (it does not search the Windows path for these, but rather paths specified with the '-I path/to/headers' and '-L path/to/libs' options in the compiler commands themselves).

You have, basically, three options here:

  1. Explicitly specify the appropriate -I and -L options on each of the individual compiler commands themselves.
  2. Set environment variables such as CPATH, C_INCLUDE_PATH, and CPLUS_INCLUDE_PATH, for header files, and LIBRARY_PATH for libraries.
  3. Install (copy) the header file(s) and DLLs into standard directories, which are already searched by the compilers automatically.

Please refer to http://mingw.org/wiki/IncludePathHOWTO and http://mingw.org/wiki/LibraryPathHOWTO for fuller details.

Note that, in the case of DLLs, the directories in which you install them must also appear in your application's (.EXE's) default DLL search path.

Also note that, if these are DLLs which you have not compiled yourself, which may have been compiled with any compiler other than MinGW's GCC/G++, and they export C++ symbols, they may not be compatible with your application, which you are compiling with MinGW's G++.