A
akash
I'm having problems calling an unmanaged class from a managed wrapper.
I suspect I'm missing something obvious, as I'm unfamiliar with C++ and
classes are very simple. My unmanaged class is as follows:
// Unmanaged.h
#pragma once
namespace Unmanaged {
class __declspec(dllexport) UnmanagedClass
{
// TODO: Add your methods for this class here.
public:
double DoUnmanagedStuff();
};
}
// Unmanaged.cpp
#include "stdafx.h"
#include "Unmanaged.h"
class UnmanagedClass
{
public:
double DoUnmanagedStuff() {
return 1.234;
}
};
This class is called from a managed wrapper as follows:
//Managed.cpp
#include "stdafx.h"
#include "Managed.h"
#include "..\Unmanaged\Unmanaged.h"
using namespace Unmanaged;
public ref class ManagedClass {
private:
UnmanagedClass* UClass;
public:
ManagedClass() {
UClass = new UnmanagedClass();
}
~ManagedClass() {
delete UClass;
}
double DoStuff() {
return UClass->DoUnmanagedStuff();
}
};
I get the following error when I try to compile the code:
error LNK2028: unresolved token (0A00000C) "public: double __thiscall
Unmanaged::UnmanagedClass:oUnmanagedStuff(void)"
(?DoUnmanagedStuff@UnmanagedClass@Unmanaged@@$$FQAENXZ) referenced in
function "public: double __clrcall ManagedClass:oStuff(void)"
(?DoStuff@ManagedClass@@$$FQ$AAMNXZ)
Any ideas what is going on?
Thanks.
I suspect I'm missing something obvious, as I'm unfamiliar with C++ and
classes are very simple. My unmanaged class is as follows:
// Unmanaged.h
#pragma once
namespace Unmanaged {
class __declspec(dllexport) UnmanagedClass
{
// TODO: Add your methods for this class here.
public:
double DoUnmanagedStuff();
};
}
// Unmanaged.cpp
#include "stdafx.h"
#include "Unmanaged.h"
class UnmanagedClass
{
public:
double DoUnmanagedStuff() {
return 1.234;
}
};
This class is called from a managed wrapper as follows:
//Managed.cpp
#include "stdafx.h"
#include "Managed.h"
#include "..\Unmanaged\Unmanaged.h"
using namespace Unmanaged;
public ref class ManagedClass {
private:
UnmanagedClass* UClass;
public:
ManagedClass() {
UClass = new UnmanagedClass();
}
~ManagedClass() {
delete UClass;
}
double DoStuff() {
return UClass->DoUnmanagedStuff();
}
};
I get the following error when I try to compile the code:
error LNK2028: unresolved token (0A00000C) "public: double __thiscall
Unmanaged::UnmanagedClass:oUnmanagedStuff(void)"
(?DoUnmanagedStuff@UnmanagedClass@Unmanaged@@$$FQAENXZ) referenced in
function "public: double __clrcall ManagedClass:oStuff(void)"
(?DoStuff@ManagedClass@@$$FQ$AAMNXZ)
Any ideas what is going on?
Thanks.