I downloaded a wrapper from the site and downloaded the library . I put the dll wrapper in the folder with the library where the exe and unmanaged dll and other library files are located. Connected dll wrapper. As I understand it, the wrapper itself connects the library. I tried to implement an example, based on the code provided on the first site.

But at the first address to the library

pin = fftwf.malloc(n*8); 

an error occurs:

Не удается загрузить DLL "libfftw3f-3.dll": Не найден указанный модуль. (Исключение из HRESULT: 0x8007007E)

I used LoadLibrary, as written in the comments, but nothing has changed, the error still appears.

How to connect the wrapper and the library?

  • Is the bit smaller? 32 | 64? - Eugene Cheverda
  • 32 - Vezd

2 answers 2

 [DllImport("kernel32.dll", CharSet=CharSet.Auto, SetLastError=true)] static extern IntPtr LoadLibrary(string filename); IntPtr handle = LoadLibrary(Path.GetFullPath(@"libfftw3f-3.dll")); if (handle != IntPtr.Zero) { // TODO: Работа с библиотечными методами } else { int error = Marshal.GetLastWin32Error(); // TODO: Обработка ошибки } 

In general, it often happens that native libraries require additional components that are not on the machine being used, for example, C Run-Time. This can be checked. For example, Dependency Walker is a very convenient utility for such purposes.

  • on Path.GetFullPath gives an error: The element "Path" does not exist in the current context. - Vezd
  • Add using System.IO; in the using section. - Nicolas Chabanovsky
  • and in what case will be executed: handle! = IntPtr.Zero? otherwise this condition is not fulfilled for me all the time and the library is therefore not used - Vezd
  • handle != IntPtr.Zero if the library has successfully loaded. If this is not the case, then you should look at the error code. - Nicolas Chabanovsky
  • The error is the same: Unable to load DLL "libfftw3f-3.dll": The specified module was not found. (Exception from HRESULT: 0x8007007E) Checked with Dependency Walker: problems appeared with the wrapper (fftwlib.dll) Question marks for modules (module not found) IESHIMS.DLL and WER.DLL. Pink icon background (warning) for MPR.DLL Warning: At least one delay-load dependency module was not found. Warning: At least one module has a function for a delay-load dependent module. - Vezd

At the end of this topic on GotDotNet there is the correct sequence of actions. The idea is that this library must be loaded via the WinAPI (kernel32.dll) LoadLibrary function.

  • But it is possible in more detail how it will look in C #, otherwise I understand almost nothing about it. Why is this not used on the first site? - Vezd