开发者

Link error in a C++/CLI application linking a static C++/CLI library

开发者 https://www.devze.com 2023-04-13 03:50 出处:网络
I have a static C++/CLI library in which the following class is defined: ObjectWrapper.h: public ref class CObjectWrapper: System::Object

I have a static C++/CLI library in which the following class is defined:

ObjectWrapper.h:

public ref class CObjectWrapper: System::Object
{
public:
    CObjectWrapper(CObject& wrappedObject);

    explicit operator CObject*();

private:
    CObject& m_WrappedObject;
};

ObjectWrapper.cpp:

#include "stdafx.h"
#include "BasicObjectWrapper.h"

CObjectWrapper::CObjectWrapper(CObject& wrappedObject)
  : WrappedObject(wrappedObject)
{ }

CObjectWrapper::operator CObject*()
{
    return &WrappedObject;
}

I have a C++/CLI application which is linked to the stat开发者_JS百科ic library. The following errors arise at link:

Error 3 error LNK2020: unresolved token (06000007) CObjectWrapper::.ctor KCBrowserInEcrinView.obj

Error 4 error LNK2020: unresolved token (06000005) CObjectWrapper::.ctor KCBrowserLibD9.lib

Error 5 error LNK2020: unresolved token (06000008) CObjectWrapper::op_Implicit KCBrowserInEcrinView.obj

Error 6 error LNK2020: unresolved token (06000006) CObjectWrapper::op_Implicit KCBrowserLibD9.lib

I solved the problem by moving the implementation (previously located in the .cpp file) to the .h file. I don't understand why.

I would highly appreciate if anybody could bring any explication.

0

精彩评论

暂无评论...
验证码 换一张
取 消