Forums

Using FFTW 3 DLL w/ CLR

Started by Unknown October 5, 2006
(This post regards compiling and linking to the FFTW library on
Windows.  Apologies if this is off-topic here.)

I'm attempting to link an application to the FFTW .lib and .dll.  I can
build and run a raw c++ sample application perfectly, as follows:

// testapp.cpp
#include "fftw3.h"
int main() {
   const unsigned int INPUT_SIZE 100;
  double* input = (double*)fftw_malloc(sizeof(double)*INPUT_SIZE);
  fftw_complex* output =
(fftw_complex*)fftw_malloc(sizeof(fftw_complex) * INPUT_SIZE);

  fftw_plan plan = fftw_plan_dft_r2c_1d(INPUT_SIZE, input, output,
FFTW_ESTIMATE | FFTW_UNALIGNED);

  for (unsigned int ir = 0; ir != N; ++ir)
	// fill input vector

  fftw_execute(plan);

  fftw_destroy_plan(plan);
  fftw_free(input);
  fftw_free(output);
}

build & link:
  cl.exe /c testapp.cpp
  link.exe /OUT:testapp.exe libfftw3-3.lib testapp.obj


However, when I move the application to the .NET CLR (that is, compile
with /clr), the app crashes with a System.TypeLoadException:

Unhandled Exception: System.TypeLoadException: Could not load type
fftw_plan_s from assembly qpFFT, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null.
   at main()

Note that this is the same exact code.  The only exception is adding
'/clr' to the compile options.

Is anyone familiar with using FFTW in a managed setting?  I'd rather
just use the first example, but, unfortunately, I'm trying to integrate
it into an application that makes heavy use of the managed extensions.

Thanks,

Ryan

rfr...@gmail.com wrote:
> (This post regards compiling and linking to the FFTW library on > Windows. Apologies if this is off-topic here.) >
Murphy's law....found it about 1 min after I posted this...some kind of versioning issue with new MS compilers: http://groups.google.com/group/microsoft.public.dotnet.languages.vc/browse_thread/thread/4d925c645c2ae163/f1b3c0a880685491?lnk=st&q=clr+dll+TypeLoadException&rnum=2&hl=en#f1b3c0a880685491
rfr...@gmail.com wrote:
> (This post regards compiling and linking to the FFTW library on > Windows. Apologies if this is off-topic here.) >
Murphy's law....found it about 1 min after I posted this...some kind of versioning issue with new MS compilers: http://groups.google.com/group/microsoft.public.dotnet.languages.vc/browse_thread/thread/4d925c645c2ae163/f1b3c0a880685491?lnk=st&q=clr+dll+TypeLoadException&rnum=2&hl=en#f1b3c0a880685491
rfr...@gmail.com wrote:
> (This post regards compiling and linking to the FFTW library on > Windows. Apologies if this is off-topic here.) >
Murphy's law....found it about 1 min after I posted this...some kind of versioning issue with new MS compilers: http://groups.google.com/group/microsoft.public.dotnet.languages.vc/browse_thread/thread/4d925c645c2ae163/f1b3c0a880685491?lnk=st&q=clr+dll+TypeLoadException&rnum=2&hl=en#f1b3c0a880685491