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

I am trying to use the Tamas Szalay C # FFTW port in Visual C # 2010, and I get the above error when I try to use a function from FFTW (in this case fftw.malloc). This error disappears if I manually move the dll to the project / 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 that I have a deeper problem.

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

0
source share
2 answers

You need to configure your project on x86 instead of Any CPU if you use external 32-bit code.

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

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

+1
source

I just wanted to clarify the situation because I am doing the same thing: I am using the x64 machine, but I installed the solution platform in Visual Studio on x86 so that I can use editing and continue.

  • There are x86 and x64 versions of the FFTW libraries. I keep them in separate directories for obvious reasons.

  • If you want to force the use of 32-bit DLLs, install the platform on x86 and copy the 32-bit FFTW DLL to the project start directory (by default, wherever it is built, for example,. \ Bin \ Debug).

Aside, I had to add CallingConvention = CallingConvention.Cdecl) to every DLLImport in FFTWlib , otherwise VS2010 will complain.

+2
source

Source: https://habr.com/ru/post/1395352/


All Articles