So I have a wrapper shown below:
Wrapper.h
#pragma once
#include "Engine.h"
namespace Wrapper
{
public ref class EngineWrapper
{
public:
EngineWrapper();
virtual ~EngineWrapper();
protected:
!EngineWrapper();
private:
CEngine *m_engine;
};
}
Wrapper.cpp
#include "stdafx.h"
#include "Wrapper.h"
using namespace Wrapper;
EngineWrapper::EngineWrapper()
{
m_engine = new CEngine();
}
EngineWrapper::~EngineWrapper()
{
if (m_engine)
{
delete m_engine;
m_engine = NULL;
}
}
EngineWrapper::!EngineWrapper()
{
if (m_engine)
{
delete m_engine;
m_engine = NULL;
}
}
and this is some of my native engine code (in another project):
Engine.h
class CEngine
{
public:
CEngine();
virtual ~CEngine();
// other stuff
}
Engine.cpp
CEngine::CEngine()
{
// do stuff
}
CEngine::~CEngine()
{
// do stuff
}
My Wrapper project is a C++/CLI project compiled using /clr
My Engine project is a native C++ project which produces a .dll, .lib, and .exp (from looking at the output when this project builds)
For the Wrapper project, I've added the location of the native .lib to the linker input.
My issue: I get the following errors:
Error 126 error LNK2028: unresolved token (0A000380) "public: __thiscall
CEngine::CEngine(void)" (??0CEngine@@$$FQAE@XZ) referenced in function "public:
__clrcall Wrapper::EngineWrapper::EngineWrapper(void)" (
0EngineWrapper@Wrapper@@$$FQ$AAM@XZ) C:\..\..\Wrapper.obj Wrapper
Error 127 error LNK2019: unresolved external symbol "public: __thiscall
CEngine::CEngine(void)" (??0CEngine@@$$FQAE@XZ) referenced in function "public:
__clrcall Wrapper::EngineWrapper::EngineWrapper(void)" (
0EngineWrapper@Wrapper@@$$FQ$AAM@XZ) C:\..\..\Wrapper.obj Wrapper
As I think it is finding the library correctly, how come it doesn't recognize the native ctor?