Question: native new linkage error

  • Thread starter Thread starter | ov
  • Start date Start date
O

| ov

Hi,
Need some help here.
I have a .NET class library in C++ (with CLR).
In this project I have a class with the __nogc keyword. When I use the
new operator within this class's code I receive:
error LNK2001: unresolved external symbol "void * __cdecl operator
new(unsigned int)" (??2@$$FYAPAXI@Z)

I think I should be able to use unmanaged runtime's new operator from
a .NET project, but I must be doing something wrong. Any ideas ?

BTW: I've referenced mscorlib

Thanks,
 
| ov said:
Hi,
Need some help here.
I have a .NET class library in C++ (with CLR).
In this project I have a class with the __nogc keyword. When I use the
new operator within this class's code I receive:
error LNK2001: unresolved external symbol "void * __cdecl operator
new(unsigned int)" (??2@$$FYAPAXI@Z)

I think I should be able to use unmanaged runtime's new operator from
a .NET project, but I must be doing something wrong. Any ideas ?

BTW: I've referenced mscorlib

Make you're linking against a version of the CRT. IIRC, for managed apps
you need to use the DLL runtime library (MSVCR70.DLL). You may need to
explicitly add msvcrt.lib to the linker settings.

-cd
 
Hi, Carl.
I've added msvcrt to both debug and release builds and now everything
works fine. Thanks you.

However, I haven't understood what you meant by: "IIRC, for managed
apps you need to use the DLL runtime library (MSVCR70.DLL)" ?

Thanks, again...
 
| ov said:
Hi, Carl.
I've added msvcrt to both debug and release builds and now everything
works fine. Thanks you.

However, I haven't understood what you meant by: "IIRC, for managed
apps you need to use the DLL runtime library (MSVCR70.DLL)" ?

When you add msvcrt.lib to the link, you're using the DLL runtime library -
msvcrt.lib is an "import library" and simply serves to make associations
between your EXE and the DLL runtime library, which is named MSVCR71.DLL if
you're using VS.NET 2003. (MSVCR70.DLL if you're using VS.NET 2002).

-cd
 
Back
Top