LNK2001 error after conversion fro FX 1.1 to FX 2.0

  • Thread starter Thread starter Urs Vogel
  • Start date Start date
U

Urs Vogel

Hi

I have a C++ interop project, which links fine with VS2003, but after
converting it to VS2005, it compiles everything withour errors/warnugs, but
I get the following linker message.

DBRDMUM.obj : error LNK2001: unresolved external symbol "?.cctor@@$$FYMXXZ"
(?.cctor@@$$FYMXXZ)

I definitely don't have a method named like this, so it must be some
compiler created symbol, but I really don't know what to look for. Any
hints? Thanks a lot.

Urs
 
Urs Vogel said:
I have a C++ interop project, which links fine with VS2003, but after
converting it to VS2005, it compiles everything withour errors/warnugs,
but I get the following linker message.

DBRDMUM.obj : error LNK2001: unresolved external symbol
"?.cctor@@$$FYMXXZ" (?.cctor@@$$FYMXXZ)
That's the module initializer. (In fact, it's the mangled name for
void __clrcall __identifier(".cctor")(); )
It is like static constructor but not associated with a particular
class. The module initializer is executed, once the assembly is
loaded (It's similar to DllMain)

VC uses it for dynamic initialization. E.g.:

// global scope
int foo();
int i = foo();

i is initialized at load time. The compiler creates a special
function (the dynamic initializer for i). Additionally it will
emit a "/include" linker directive for the module
initializer in the object file and the /DEFAULTLIB for the
managed CRT.

When the linker sees the directive, it includes the module
initializer even if it is not otherwise referenced. It is
defined in the managed CRT.

So what you need is the correct libraries. In VC 8 it is
no longer necessary to use /NOENTRY, /NODEFAULTLIB
(linker) or /Zl (compiler) etc. Just let the tool chain figure it out.

Dumpbin /DIRECTIVES should reveal the implied
linker switches for a given object file.

If that doesn't help can you post linker warnings and
the result of dumpbin /DIRECTIVES along with
the command line switches for the linker and compiler?

-hg
 
Found it out. Removed /Zl, removed msvcrt.lib from dependecies, removed /noentry. Works now. Your hints brought me on path. Thanks.


Hi Holger

Thanks for your hints. Dind't really help me any farther, dumpbin
/Directoves list and build log are in the attachment.

Any tips are appreciated ... Thanks.
 
Back
Top