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

╄→гoц情女王★ 提交于 2019-12-12 02:13:05

问题


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.


回答1:


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.




回答2:


Just wanted to clarify things here since I am doing exactly the same thing: I am using an x64 machine but I set the platform of the solution in Visual Studio to x86 so I can use edit and continue.

  1. There are both x86 and x64 versions of the FFTW DLL's. I keep them in separate directories for obvious reasons.

  2. If you want to force use of the 32-bit DLL's, then set your platform to x86 and copy the 32-bit FFTW DLL's to the starting directory of the project (defaults to wherever it builds; for example, .\bin\Debug).

As an aside, I had to add CallingConvention = CallingConvention.Cdecl) to every DLLImport statement in FFTWlib otherwise VS2010 would complain.



来源:https://stackoverflow.com/questions/9170885/using-fftwlib-c-cannot-find-libfftw3-3-dll

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!