Search code examples
c#.netfftw

**Help** with Upgrading FFTW.NET wrapper to .Net7/Net Core


I am attempting to upgrade the FFTW.NET wrapper to .NET 7 on my project using the FFTW.NET by ArgusMagnus@github. My project will not compile and is producing definition errors like:

Error code: CS0117 'FftwInterop' does not contain a definition

[List of all errors]https://i.sstatic.net/yXpcQ.png

I believe the template file is not being compiled all the way through to create the '*.g.cs' file. Next, I am confused that the README says to change the names of the '.dll' files to "libfftw3-3-x86.dll" and "libfftw3-3-x64.dll" but after downloading the files there are 3 differently named '.dll' files? Then it says to put them into the application directory. What is the correct application directory?

README

fftw-3.3.5-dll64 (win64 FFTW download)

Anything will help due to the lack of information over this issue...


Solution

  • I believe the template file is not being compiled all the way through to create the '*.g.cs' file.

    Correct. That is the problem. The .csproj file for FFTW.NET.csproj does not currently run T4 (TextTemplatingFileGenerator) on-build: instead you have to manually run T4 via Visual Studio (right-click the FftwInterop.tt file and choose "Run custom tool" to generate the FftwInterop.g.cs.

    The T4 file doesn't have any dependenencies: it's just a (glorified) self-contained macro-expansion that generates all those DllImport methods from a simple list of exported functions hardcoded in the T4 file (so I'm surprised the FftwInterop.g.cs file is excluded from source-control via gitignore as there's no reason not to include it, not least for the benefit of users without T4 in their build environment)

    FWIW, I ported the https://github.com/ArgusMagnus/FFTW.NET project from .NET Standard 1.3 to .NET 5 and posted it to my GitHub fork here: https://github.com/daiplusplus/FFTW.NET which builds just fine in VS2019 (as of commit 12e4d3dce).

    Next, I am confused that the README says to change the names of the '.dll' files to "libfftw3-3-x86.dll" and "libfftw3-3-x64.dll" but after downloading the files there are 3 differently named '.dll' files?

    • I downloaded the .dll files from this page: http://www.fftw.org/install/windows.html
    • Each .zip file contains 3 different builds of libfftw3{type}-3.dll, where {type} is either empty, f, or l - these 3 builds correspond to the "single/long/long-double" floating-point types.
      • The FFTW.NET library only seems to support the single-precision build (i.e. libfftw3-3.dll) so copy fftw-3.3.5-dll32.zip\libfftw3-3.dll into the same directory as the FFTW.NET.csproj file and rename it to libfftw3-3-x86.dll - do the same for fftw-3.3.5-dll64.zip\libfftw3-3.dll but rename that to libfftw3-3-x64.dll.

    Like so:

    enter image description here

    Then it says to put them into the application directory. What is the correct application directory?

    Ignore that instruction; instead you'll want those .dll files to be included in the .csproj output, so do this:

    • First, you need to include those .dll files in the .csproj file as Content, configured to copy-if-newer.
      • The .dll files will appear in Solution Explorer automatically once they're moved into the same directory as the .csproj, but they'll appear as "Build action: None" - you need to change that to "Content" and "Copy if newer", like so:

    enter image description here


    Then run the TestAppNet5 project and it should just work:

    enter image description here