473,511 Members | 15,046 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question: native new linkage error

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,
Nov 17 '05 #1
3 1055
| ov wrote:
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
Nov 17 '05 #2
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...

"Carl Daniel [VC++ MVP]" <cp*****************************@mvps.org.nospam > wrote in message news:<Oy**************@TK2MSFTNGP12.phx.gbl>...
| ov wrote:
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

Nov 17 '05 #3
| ov wrote:
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
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
12103
by: qazmlp | last post by:
const has internal linkage in C++, but external linkage in C. Am I right ? But, linker reports multiply-defined error if the following header is included in multiple .cpp files. //...
4
3244
by: usr2003 | last post by:
I wrote the following test program to test the linkage directives extern "C": #include <stdio.h> extern "C" {
47
3800
by: Richard Hayden | last post by:
Hi, I have the following code: /******************************** file1.c #include <iostream> extern void dummy(); inline int testfunc() {
53
4020
by: Jeff | last post by:
In the function below, can size ever be 0 (zero)? char *clc_strdup(const char * CLC_RESTRICT s) { size_t size; char *p; clc_assert_not_null(clc_strdup, s); size = strlen(s) + 1;
8
2131
by: amirr | last post by:
Guys, As you know static member functions do not have a this pointer. so instead, what shall i do? for example ... consider I want to call Code: ( text ) 1.
3
2265
by: CrazyJohn | last post by:
Hi guys, This is my first time posting question here, if I break any rules, please kindly point out. And I'm really glad to be a part of this community. Here is my question, Our lecturer...
1
1501
by: Kurt | last post by:
The C++ standard (in 3.5:6, p42Example) said: static int i = 0; // 1 void g() { int i; //2: i has no linkage { extern int i; //3: external linkage
12
2996
by: Bryan Parkoff | last post by:
I write my large project in C++ source code. My C++ source code contains approximate four thousand small functions. Most of them are inline. I define variables and functions in the global scope....
54
3550
by: shuisheng | last post by:
Dear All, I am always confused in using constants in multiple files. For global constants, I got some clues from http://msdn.microsoft.com/en-us/library/0d45ty2d(VS.80).aspx So in header...
0
7237
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7137
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7349
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7417
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5659
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5063
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4734
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3210
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
445
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.