所以我有一个如下所示的包装器:
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;
}
}
这是我的一些原生引擎代码(在另一个项目中):
Engine.h
class CEngine
{
public:
CEngine();
virtual ~CEngine();
// other stuff
}
Engine.cpp
CEngine::CEngine()
{
// do stuff
}
CEngine::~CEngine()
{
// do stuff
}
My Wrapper项目是使用/clr
编译的C ++ / CLI项目
My Engine项目是一个本机C ++项目,它生成.dll,.lib和.exp(从这个项目构建时查看输出)
对于Wrapper项目,我已将原生.lib的位置添加到链接器输入。
我的问题:我收到以下错误:
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
我认为正确找到了库,为什么它不能识别本地ctor?