Search code examples
c#fftfftw

Using FFTWLib (C#): Cannot find libfftw3-3.dll


I'm trying to use Tamas Szalay's C# port of FFTW in Visual C# 2010, and I'm getting the above error when I try to use a function from FFTW (in this case fftw.malloc). That error goes away if I manually move the dll into the project's /bin/debug/ folder, but then I get

An attempt was made to load a program with an incorrect format.
(Exception from HRESULT: 0x8007000B)
Method: IntPtr malloc(Int32)

which makes me think I have a deeper problem.

Possibly relevant: I'm running this on an x64 machine, and DependencyWalker says that fftwlib.dll is built for x86.


Solution

  • You got to set your project CPU configuration to x86 instead of Any CPU if you are using external 32 bit code.

    Any CPU is the default Visual Studio configuration, if you are running on a 64 bit OS, it will by default compile as 64 bit code, the problem is that if you need to load 32 bit DLLs like in your case, you will get format errors.

    http://cl.ly/3s1J2q3u3E0n2F2y0z1K <-- screenshot where it is located.