- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I am trying to use FFTW in VS9.0+IVF environment.
I have downloaded FFTW, unzip it, and generate all the .lib files using the method mentioned in the FFTW mannual.
Also, I have put the necessary .dll files to C:\\Windows\\System32, and put all the .lib files to IVF's lib directory. And I have put all the .lib files' name in the Linker->Input or Linker->General.
In the source code, I have also put include 'fftw3.f' at the begining.
However, when I try to compile and run the program, it seems that I can pass the compilation, but there is something missing when Linking:
1>Fourier2D.for
1>Linking...
1>Fourier2D.obj : error LNK2019: unresolved external symbol DFFTW_PLAN_DFT_2D referenced in function FFT2
1>Fourier2D.obj : error LNK2019: unresolved external symbol DFFTW_EXECUTE_DFT referenced in function FFT2
1>Fourier2D.obj : error LNK2019: unresolved external symbol DFFTW_DESTROY_PLAN referenced in function FFT2
1>x64\\Release\\PseudoAcousticTTIPseudoSpectral.exe : fatal error LNK1120: 3 unresolved externals
I cannot figure out what is the problem.
Please help. Thanks a lot.
Link Copied
17 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you take care to choose either 32-bit or 64-bit mode throughout? If the .obj and .lib file /machine tags don't match, you might expect the unresolved references.
Putting your .dll in System32 helps proliferate such confusion.
Putting your .dll in System32 helps proliferate such confusion.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes they are matched. I lib the def file like:
lib /machine:x64 /def:libfftw3-3.def
... 3f-3.def
... 3l-3.def
But still does not work...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The FFTW routines are written in C and therefore would have different naming conventions than Fortran. I see that FFTW 3.3 adds Fortran 2003 bindings using the C interoperability support which should take care of this - are you using them?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, Steve,
I have tried that, following the instructions in FFTW manual
use, intrinsic :: iso_c_binding include 'fftw3.f03'
And modifies the definitions in the source code, but it doest not work.
Also, I try to use MKL's FFTW interface, but seems that the same problem appears, i.e., unresolved externals ...
Thanks a lot.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You would need those lines in every subroutine where you called the FFTW routines. That you are getting the uppercase undefineds tells me that you are not doing this.
If you need help using MKL, please ask in the MKL forum.
If you need help using MKL, please ask in the MKL forum.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
FFTW is a C library, with limited support from the authors for mixed-language programming on Windows. The combinations of compilers, versions, and compiler options are so many in this scenario that it is very easy to get things wrong. I note that you are using the prebuilt binary distribution of FFTW-3.
Your attempt to use the F2003 C-interoperability feature may have failed because on Windows gcc-mingw-32 is not a "companion C processor" to Intel Fortran.
The closest that I can think of as something useful to you is to take one of the FFTW examples from the current MKL distribution, namely,
\examples\fftw3xf\sp_plan_dft.f90
and the 32-bit binary distribution
ftp://ftp.fftw.org/pub/fftw/fftw-3.3-dll32.zip
Build the import library:
lib /def:libfftw3f-3.def /machine:i386
Build the example, using naming conventions to match the Mingw-32 environment for which the FFTW3 DLLs were built:
ifort /Qlowercase /us sp_plan_dft.f90 libfftw3-3f.lib
and run the resulting EXE file.
The same compiler options may be used if you use the FFTW3 DLLS for Mingw-64 and Ifort-x64.
Your attempt to use the F2003 C-interoperability feature may have failed because on Windows gcc-mingw-32 is not a "companion C processor" to Intel Fortran.
The closest that I can think of as something useful to you is to take one of the FFTW examples from the current MKL distribution, namely,
and the 32-bit binary distribution
ftp://ftp.fftw.org/pub/fftw/fftw-3.3-dll32.zip
Build the import library:
lib /def:libfftw3f-3.def /machine:i386
Build the example, using naming conventions to match the Mingw-32 environment for which the FFTW3 DLLs were built:
ifort /Qlowercase /us sp_plan_dft.f90 libfftw3-3f.lib
and run the resulting EXE file.
The same compiler options may be used if you use the FFTW3 DLLS for Mingw-64 and Ifort-x64.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, but I don't agree with mecej4 here. FFTW provides a set of interface blocks in the INCLUDE that use BIND(C) correctly to map the C names for Fortran. This should work just fine for Intel Fortran. As I wrote earlier, the linker messages with uppercase routine names tells me that Fortran is NOT seeing the interface blocks, which all specify lowercase names. I recommend against using /names to make up for this as there may be other issues this hides.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, Steve,
Thanks again for the answers. Below is my small subroutine I am trying to write to implement a two dimensional real-to-complex FFT using FFTW:
!////////////////////////////////////////////////////////////////////////
! Fast Fourier Transform for 2D array from real to complex
!////////////////////////////////////////////////////////////////////////
subroutine fft2(InputArray,OutputArray,xmax,zmax)
use, intrinsic :: iso_c_binding
include 'fftw3.f90'
!implicit none
integer xmax,zmax
real,dimension(1:xmax,1:zmax)::InputArray
complex,dimension(1:xmax,1:zmax)::OutputArray
!----------------------------------------------------
! 2D forward FFT by FFTW
!----------------------------------------------------
!integer*8 plan
!complex,dimension(1:xmax,1:zmax)::temp
type(C_PTR) plan
complex(c_complex),dimension(1:xmax,1:zmax)::temp
temp=cmplx(InputArray)
call sfftw_plan_dft_2d(plan,zmax,xmax,temp,temp,FFTW_FORWARD,FFTW_ESTIMATE)
call sfftw_execute_dft(plan,temp,temp)
call sfftw_destroy_plan(plan)
OutputArray=temp
end subroutine fft2
The original file contained in FFTW for fortran is fftw3.f03, which I cannot use in this subourinte. I therefore change it to fftw3.f90, with contents unchanged. However, the error now is
1>E:\Projects\lib\FFT\FFTW\fftw3.f90(428): error #6684: This is an incorrect value for a kind type parameter in this context. [C_FFTW_R2R_KIND]
An error from that fftw3.f90 file. I am not sure why this happens and how to solve it.
Thanks a lot.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry the .f03 file can be used, but the compiling will have same error, i.e., eror #6684
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve, the three FFTW3 routines called by the user are called using the F77 interface:
DFFTW_EXECUTE_DFT
DFFTW_EXECUTE_DFT
DFFTW_DESTROY_PLAN
There are no entries to match these in the file fftw3.f03 provided with FFTW3.
Of course, the user can write interface definitions for these (and others that his/her code may call) and add them to fftw3.f03, but they do not exist in the FFTW3 distribution that was used. I do not know if they exist elsewhere.
Do you have tools to generate such interfaces?
DFFTW_EXECUTE_DFT
DFFTW_EXECUTE_DFT
DFFTW_DESTROY_PLAN
There are no entries to match these in the file fftw3.f03 provided with FFTW3.
Of course, the user can write interface definitions for these (and others that his/her code may call) and add them to fftw3.f03, but they do not exist in the FFTW3 distribution that was used. I do not know if they exist elsewhere.
Do you have tools to generate such interfaces?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is a modified version of your subroutine that I can link successfully (up to a point: no main program is provided), using the deprecated options /Qlowercase /us .
[fxfortran] !//////////////////////////////////////////////////////////////////////// ! Fast Fourier Transform for 2D array from real to complex !//////////////////////////////////////////////////////////////////////// subroutine fft2(InputArray,OutputArray,xmax,zmax) !use, intrinsic :: iso_c_binding implicit none include 'fftw3.f' integer xmax,zmax real,dimension(1:xmax,1:zmax)::InputArray complex,dimension(1:xmax,1:zmax)::OutputArray !---------------------------------------------------- ! 2D forward FFT by FFTW !---------------------------------------------------- integer*8 plan complex,dimension(1:xmax,1:zmax)::temp ! type(C_PTR) plan ! complex(c_complex),dimension(1:xmax,1:zmax)::temp temp=cmplx(InputArray) call sfftw_plan_dft_2d(plan,zmax,xmax,temp,temp,FFTW_FORWARD,FFTW_ESTIMATE) call sfftw_execute_dft(plan,temp,temp) call sfftw_destroy_plan(plan) OutputArray=temp end subroutine fft2[/fxfortran]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, mecej4,
Thanks very much for your answer. I am still trying. I tested /Qlowercase in the command line option for my project, but seems it cannot solve this problem...
Thanks,
K
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, mecej4,
I've just seen your modification. Thanks a lot. Let me try this.
K
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The /Qlowercase option by itself will not help; you also need the /us option since the Mingw DLLs have those underscores. Calling the file with the modified code in #11 as fftx.f,
ifort /MD /us /Qlowercase /extend_source fftx.f libfftw3f-3.lib
gives
-out:fftx.exe
-subsystem:console
fftx.obj
libfftw3f-3.lib
libifcoremd.lib(for_main.obj) : error LNK2019: unresolved external symbol MAIN__ referenced in function main
fftx.exe : fatal error LNK1120: 1 unresolved externals
Note that the references to the FFTW3 libraries were successfully resolved by the linker.
ifort /MD /us /Qlowercase /extend_source fftx.f libfftw3f-3.lib
gives
-out:fftx.exe
-subsystem:console
fftx.obj
libfftw3f-3.lib
libifcoremd.lib(for_main.obj) : error LNK2019: unresolved external symbol MAIN__ referenced in function main
fftx.exe : fatal error LNK1120: 1 unresolved externals
Note that the references to the FFTW3 libraries were successfully resolved by the linker.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, mecej4,
Thanks a lot. It works. But the allowed array is quite limited. For example, if I test a 400*400 array, the subroutine will return that stack overflow. Perhaps I should change the options for that. But anyway, I can now use FFTW in fortran now.
Thanks,
K
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, Steve,
Thanks very much for your answers. I think now I can use FFTW in fortran now by adjusting those lowercase things. I've learned a lot from this.
Really appreciate your help.
Thanks,
K
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The issue of stack limits is a totally different matter. You can raise the stack limit, use allocated arrays, or use the /heap-arrays option.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page