简体   繁体   中英

Using an interface from another project in VS2012

I am currently trying to inherit from a c++ interface defined as such:

class IWindow: public Initializable
{
public:
    virtual ~IWindow(void) =0;

    virtual BOOL IsVisible(void) =0;
    virtual void Show(BOOL inbShow) =0;
};

This interface is defined in a separate project from the class which is trying to inherit from it. That class is defined as such:

#include "IWindow.h"

class Win32Window: public IWindow
{
    HGLRC m_renderingContext;
    HWND m_win32Handle;
    HDC m_deviceContext;

    BOOL m_bVisible;
public:
    Win32Window(void);
    virtual ~Win32Window(void);

    virtual void Initialize(void);
    virtual void Destroy(void);

    virtual BOOL IsVisible(void);
    virtual void Show(BOOL inbShow);
};

I am getting an external symbol issue on the publicly defined pure virtual constructor of IWindow the exact error message reads:

1>Win32Window.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall IWindow::~IWindow(void)" (??1IWindow@@UAE@XZ) referenced in function "public: virtual __thiscall Win32Window::~Win32Window(void)" (??1Win32Window@@UAE@XZ)

I cannot seem to understand why this error is occuring as far as I was aware whether or not a class is in another project should not matter as long as the file is #included into the inheriting class's header file. Can anyone explain this error to me and possibly provide a solution to this error? I eventually plan to have the class IWindow as part of a dll but until then I need to be able to compile and test this solution with the files within multiple different projects.

You have an error message about undefined pure virtual destructor .

A destructor, even if it's pure virtual, must have an implementation. Most likely a .cpp file with implementation of the IWindow::~IWindow() is not included into the project. That's why linker cannot find it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM