473,396 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Error Mixing Managed and Unmanaged Code

I've never mixed managed and unmanaged C++ before, but I've done a lot
of "research" out on the web. Using some examples out there, I wrote this:

#using <mscorlib.dll>
using namespace System;

namespace ntMgdCls
{
__nogc class ntUnmgdCls
{
public:
ntUnmgdCls::ntUnmgdCls(void) {}
ntUnmgdCls::~ntUnmgdCls(void) {}
int ntUnmgdCls::DoSomethingUnmanaged(void) { return 1; }
};

public __gc class ntManagedClass
{
public:
int DoSomething(void)
{
ntUnmgdCls * umc = new ntUnmgdCls();
return umc->DoSomethingUnmanaged();
}
};
}

Essentially I want ntUnmgdCls to wrap around some C++ classes that I
need to import from a 3rd party .lib, and use that wrapper from our main
C# app. However, when I do the above, I get these linker failures:

ntMgdCls.obj : error LNK2001: unresolved external symbol "void * __cdecl
operator new(unsigned int)" (??2@$$FYAPAXI@Z)
ntMgdCls.obj : error LNK2001: unresolved external symbol "void __cdecl
operator delete(void *)" (??3@$$FYAXPAX@Z)

I'm sure it's something basic that I'm missing, and figured someone out
here could pick out what's going on in a NY second...my WY seconds are a
bit slower...

Thanks in advance!

Jared

Oct 23 '06 #1
2 1331
compile you program with /clr:oldsyntax and see if that helps

"Jared Kail" wrote:
I've never mixed managed and unmanaged C++ before, but I've done a lot
of "research" out on the web. Using some examples out there, I wrote this:

#using <mscorlib.dll>
using namespace System;

namespace ntMgdCls
{
__nogc class ntUnmgdCls
{
public:
ntUnmgdCls::ntUnmgdCls(void) {}
ntUnmgdCls::~ntUnmgdCls(void) {}
int ntUnmgdCls::DoSomethingUnmanaged(void) { return 1; }
};

public __gc class ntManagedClass
{
public:
int DoSomething(void)
{
ntUnmgdCls * umc = new ntUnmgdCls();
return umc->DoSomethingUnmanaged();
}
};
}

Essentially I want ntUnmgdCls to wrap around some C++ classes that I
need to import from a 3rd party .lib, and use that wrapper from our main
C# app. However, when I do the above, I get these linker failures:

ntMgdCls.obj : error LNK2001: unresolved external symbol "void * __cdecl
operator new(unsigned int)" (??2@$$FYAPAXI@Z)
ntMgdCls.obj : error LNK2001: unresolved external symbol "void __cdecl
operator delete(void *)" (??3@$$FYAXPAX@Z)

I'm sure it's something basic that I'm missing, and figured someone out
here could pick out what's going on in a NY second...my WY seconds are a
bit slower...

Thanks in advance!

Jared
Oct 23 '06 #2
Hi. Thanks for the suggestion!!! Unfortunately, I'm using VS2003 (.NET
1.1), so the oldsyntax trick won't work.

Anyone have any other ideas? It seems like this should be pretty
straightforward. What I am missing?

Jared

Vikas Kumar wrote:
compile you program with /clr:oldsyntax and see if that helps

"Jared Kail" wrote:

>I've never mixed managed and unmanaged C++ before, but I've done a lot
of "research" out on the web. Using some examples out there, I wrote this:

#using <mscorlib.dll>
using namespace System;

namespace ntMgdCls
{
__nogc class ntUnmgdCls
{
public:
ntUnmgdCls::ntUnmgdCls(void) {}
ntUnmgdCls::~ntUnmgdCls(void) {}
int ntUnmgdCls::DoSomethingUnmanaged(void) { return 1; }
};

public __gc class ntManagedClass
{
public:
int DoSomething(void)
{
ntUnmgdCls * umc = new ntUnmgdCls();
return umc->DoSomethingUnmanaged();
}
};
}

Essentially I want ntUnmgdCls to wrap around some C++ classes that I
need to import from a 3rd party .lib, and use that wrapper from our main
C# app. However, when I do the above, I get these linker failures:

ntMgdCls.obj : error LNK2001: unresolved external symbol "void * __cdecl
operator new(unsigned int)" (??2@$$FYAPAXI@Z)
ntMgdCls.obj : error LNK2001: unresolved external symbol "void __cdecl
operator delete(void *)" (??3@$$FYAXPAX@Z)

I'm sure it's something basic that I'm missing, and figured someone out
here could pick out what's going on in a NY second...my WY seconds are a
bit slower...

Thanks in advance!

Jared

Oct 27 '06 #3

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

Similar topics

2
by: Neil | last post by:
I am developing a demo in C# using Managed DirectX. I wanted to use a C++ static library in the demo (its a class for handling physics), so I decided to create my Graphics classes in C#, inherit...
4
by: Daniel Lidström | last post by:
Hello, is it possible to ``use CS to code a class, and (M)C++ for the logic''? Sorry if this sounds vague, I'm not really sure myself what it means. Does anyone have any ideas? -- Daniel
14
by: Jon | last post by:
Whether I can compile a class or not, depends on the order of functions in my class. My question is (see example below): 1) Is it a bug that the class 'WillCompile' will compile and execute, or...
1
by: tsmith | last post by:
Hello, Quick question: Can I mix managed C++ (forms and GUI stuff) with nonmanaged C++ code (Direct3D). Note that I am not interested in managed DX (the C# API). I still am writing C++ code,...
13
by: DD | last post by:
I'm puzzled how to mix managed/unmanaged C++ in the following scenario: Unmanaged ------------ Callback listener class with method that should call an event in managed Form1. Initialization...
3
by: Wayne Allen | last post by:
I am receiving a compile error when attempting to include Directshow in a managed C++ program using Visual C++ 2005 Express Edition Version 8. The ..NET framework is version 2.0.50727. To...
2
by: quat | last post by:
I am getting the error: error C4368: cannot define 'd3dPP' as a member of managed 'FormEx::Form1': mixed types are not supported I am trying to mixed managed and unmanaged code (d3dPP is...
3
by: frank | last post by:
Hi I've got aplication, which one is written in unmanaged c++ with stl, i've made for it gui in managed c++. Problem becomes when I'm starting to filling up for example datagrids, when I'm...
3
by: frank | last post by:
Hi I've got aplication, which one is written in unmanaged c++ with stl, i've made for it gui in managed c++. Problem becomes when I'm starting to filling up for example datagrids, when I'm...
2
by: Jon Slaughter | last post by:
How difficult is it for one to integrate unmanaged C++ into C#? I know for functions one can use DLLimport but how does one go about doing it for classes? Do I have to completely reimplement the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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...

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.