473,586 Members | 2,776 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 1058
| 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.nos pam> wrote in message news:<Oy******* *******@TK2MSFT NGP12.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
12115
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. // test_const.h #ifndef HEADER_TEST #define HEADER_TEST
4
3252
by: usr2003 | last post by:
I wrote the following test program to test the linkage directives extern "C": #include <stdio.h> extern "C" {
47
3830
by: Richard Hayden | last post by:
Hi, I have the following code: /******************************** file1.c #include <iostream> extern void dummy(); inline int testfunc() {
53
4042
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
2133
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
2271
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 told us that Unnamed Namespace is an alternative to Static Internal Variables, but he also said that Namespace has an
1
1510
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
3003
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. The global variables and global functions are hidden to prevent from accessing by the programmers. All global functions share global variables....
54
3575
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 file writing: const double PI = 3.14; Every time using it, include the header file.
0
7911
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8200
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7954
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8215
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6610
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5390
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1448
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1179
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.