Baffling unresolved token error

B

Brian Victor

I'm trying to get FFTW (fftw.org) to work in such a way that it can be
called from a managed C++ module. The approach I've found to generate
the fewest linker errors is a mixed managed/unmanaged project.
However, that still produces the following from the linker:

FFTW2 error LNK2020: unresolved token (0A0000C6) fftw_execute

Running ildasm on the resulting dll shows:

..method public static unmanagedexp void
modopt([mscorlib]System.Runtime.CompilerServices.CallConvCdecl)
fftw_execute(valuetype fftw_plan_s*
modopt([Microsoft.VisualC]Microsoft.VisualC.IsConstModifier) p) cil
managed

Other calls to FFTW with similar disassemblies link without complaint.
Commenting my call to fftw_execute causes the program to link. What
might be causing the link failure in this case?

Any ideas would be helpful. I've been working on this for a week and
am totally stumped. Thanks!
 
B

Brian Victor

Replying to myself with more info, I tried once again to compile FFTW
as an non-CLR .lib rather than a CLR .dll. This causes it to link but
fail at runtime with the following:

An unhandled exception of type 'System.TypeLoadException' occurred in
mymodule.dll

Additional information: Could not load type fftw_plan_s from assembly
MyModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null.

fftw_plan_s is an internal structure in FFTW. It is not exposed as
part of the public interface, except as a pointer typedef to fftw_plan
which I am using. Do I need to do something to expose this struct to
the unmanaged CLR C++ code?
 
R

Ronald Laeremans [MSFT]

Brian said:
Replying to myself with more info, I tried once again to compile FFTW
as an non-CLR .lib rather than a CLR .dll. This causes it to link but
fail at runtime with the following:

An unhandled exception of type 'System.TypeLoadException' occurred in
mymodule.dll

Additional information: Could not load type fftw_plan_s from assembly
MyModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null.

fftw_plan_s is an internal structure in FFTW. It is not exposed as
part of the public interface, except as a pointer typedef to fftw_plan
which I am using. Do I need to do something to expose this struct to
the unmanaged CLR C++ code?

What version of the compiler are you using? If it is the 2003 / 7.1
version you need to add an empty definition for fftw_plan_s. If you are
using the 2005 / 8.0 version the linker will add that for you (and
generate a warning telling you it did).

The CLR needs to have a definition of a type available even to create a
pointer to it.

Ronald Laeremans
Visual C++ team
 
B

Brian Victor

Ronald said:
What version of the compiler are you using? If it is the 2003 / 7.1
version you need to add an empty definition for fftw_plan_s. If you are
using the 2005 / 8.0 version the linker will add that for you (and
generate a warning telling you it did).

Thanks for replying, Ronald. I am using 2003/7.1. I've become pretty
comfortable in my workaround at this point, but if I come across the
problem again I'll give that a shot.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top