c++ - error LNK2019 未解析的外部符号 - 类库问题?

标签 c++ visual-studio-2013 lnk2019

我有一个包含 2 个项目的解决方案。 (VS2013)

一个项目是带有 XAML 的 Direct3D 项目,另一个是静态类库。

我已经设置了项目依赖。

enter image description here

我想知道未解析的外部符号是否与此有关。

这是我遇到的错误...我发现很难理解它们的含义

Error   1   error LNK2019: unresolved external symbol "public: __thiscall Game::Model::Input::Keyboard::Keyboard(void)" (??0Keyboard@Input@Model@Game@@QAE@XZ) referenced in function "public: __cdecl Game::App::App(void)" (??0App@Game@@Q$AAA@XZ)    C:\Users\James\Documents\Visual Studio 2013\Projects\Games\Jimmy\Game\App.xaml.obj  Game
Error   2   error LNK2019: unresolved external symbol "public: __thiscall Game::Model::Entities::Player::Player(void)" (??0Player@Entities@Model@Game@@QAE@XZ) referenced in function "public: void __thiscall Game::PlayerRenderer::InstantiateDependantObjects(void)" (?InstantiateDependantObjects@PlayerRenderer@Game@@QAEXXZ)  C:\Users\James\Documents\Visual Studio 2013\Projects\Games\Jimmy\Game\PlayerRenderer.obj    Game
Error   3   error LNK1120: 2 unresolved externals   C:\Users\James\Documents\Visual Studio 2013\Projects\Games\Jimmy\Debug\Game\Game.exe    1   1   Game

这是它正在努力处理的代码的一部分:

模型项目

模型\实体\键盘.h

#pragma once

namespace Game
{
    namespace Model
    {
        namespace Input
        {
            class Keyboard
            {
            public:
                Keyboard();

                bool Up;
                bool Down;
                bool Left;
                bool Right;
                bool Space;
                bool Escape;
            };
        }
    }
}

模型\实体\键盘.cpp

#include "pch.h"

#include "Entities\Keyboard.h"

using namespace Game::Model::Input;

Keyboard::Keyboard()
:   Up( FALSE ),
    Down( FALSE ),
    Left( FALSE ),
    Right( FALSE ),
    Space( FALSE ),
    Escape( FALSE )
{}

游戏项目

游戏\App.xaml.h

#pragma once

...
#include "..\Model\Entities\Keyboard.h"    
...

using namespace Game::Model::Input;

namespace Game
{
    ref class App sealed
    {
    public:
        ...    
    private:
        ...         
            Keyboard* keyboard;    
            ...
    };
}

游戏\App.xaml.cpp

App::App()
{
    InitializeComponent();
    keyboard = new Keyboard();
    Suspending += ref new SuspendingEventHandler(this, &App::OnSuspending);
    Resuming += ref new EventHandler<Object^>( this, &App::OnResuming );
}

...

有什么想法吗?

最佳答案

该对话框没有按照您希望的方式执行,您实际上并未链接您的静态库项目。它曾经在 VS2010 之前的旧 VS 版本中使用,现在它只设置构建顺序。

相反,使用项目 + 属性、通用属性、引用。单击“添加新引用”按钮并勾选您的库项目。

关于c++ - error LNK2019 未解析的外部符号 - 类库问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22314917/

相关文章:

c++ - 运算符重载赋值运算符

mysql - Visual Studio 2013 无法使用字符串连接到 MySQL 数据库,但可以使用数据源窗口

vb.net - 如何在 Visual Studio 2013 上进入设计 View ?

c++ - 链接错误 LNK1120 和 LNK2019 - "unresolved external symbol _main"

c++ - LNK2019 和 LNK1120 具有外部文件中的功能

c++ - 如何在 C++ 中使用 time.h 消除警告?

c++ - 如何在 SuperpixelSLIC 中找到段的唯一标签

c++ - 尝试在 hash_map 中查找记录时应用程序崩溃

colors - Visual Studio 2013 不突出显示 typescript 文件

c++ - LNK2019 : unresolved extrenal symbol when using std::ifstream