G
Guest
The project that I am on is going to require me to mix managed and unmanaged
code. I created a vc++ class library (.net) project bane TestLib.
I inserted the following test code in testLib.h. The code came from the MS
example on mixing managed and unmanaged code. When I build the project, I get
two unresolved external symbols on from the MClass Constructor and
Destructor. I'll guess I am missing a build switch. The doc says I need /clr
and /LD but they have no affect. The actual link errors follow the code.
Thanks in advance...Chuck
// TestLib.h
#pragma once
using namespace System;
namespace TestLib
{
class CppClass
{
public:
// constructor
CppClass() {}
// destructor
~CppClass() {}
// methods
void native_f() {}
};
public __gc class MClass
{
public:
// constructor
MClass() { m_pC = new CppClass(); }
// destructor
~MClass() { delete m_pC; }
// method
void managed_f() { m_pC->native_f(); }
private:
CppClass * m_pC;
};
}
Compiling...
TestLib.cpp
Linking...
TestLib.obj : error LNK2001: unresolved external symbol "void * __cdecl
operator new(unsigned int)" (??2@$$FYAPAXI@Z)
TestLib.obj : error LNK2001: unresolved external symbol "void __cdecl
operator delete(void *)" (??3@$$FYAXPAX@Z)
D:\Source Files\statrad\ScannerTest\Debug\TestLib.dll : fatal error LNK1120:
2 unresolved externals
code. I created a vc++ class library (.net) project bane TestLib.
I inserted the following test code in testLib.h. The code came from the MS
example on mixing managed and unmanaged code. When I build the project, I get
two unresolved external symbols on from the MClass Constructor and
Destructor. I'll guess I am missing a build switch. The doc says I need /clr
and /LD but they have no affect. The actual link errors follow the code.
Thanks in advance...Chuck
// TestLib.h
#pragma once
using namespace System;
namespace TestLib
{
class CppClass
{
public:
// constructor
CppClass() {}
// destructor
~CppClass() {}
// methods
void native_f() {}
};
public __gc class MClass
{
public:
// constructor
MClass() { m_pC = new CppClass(); }
// destructor
~MClass() { delete m_pC; }
// method
void managed_f() { m_pC->native_f(); }
private:
CppClass * m_pC;
};
}
Compiling...
TestLib.cpp
Linking...
TestLib.obj : error LNK2001: unresolved external symbol "void * __cdecl
operator new(unsigned int)" (??2@$$FYAPAXI@Z)
TestLib.obj : error LNK2001: unresolved external symbol "void __cdecl
operator delete(void *)" (??3@$$FYAXPAX@Z)
D:\Source Files\statrad\ScannerTest\Debug\TestLib.dll : fatal error LNK1120:
2 unresolved externals