C++ Direct2D - 从笔记本电脑移动正弦文件后出现链接器错误 2019
C++ Direct2D - Linker error 2019 after moving sine files from my laptop
我想将我在笔记本电脑上编写的一些代码移动到另一台 PC 上。我没有使用Github或任何其他类型的源代码管理,我只是简单地将c ++文件复制到USB驱动器上并将它们放在我的另一台PC上。
现在,由于某种原因,当我尝试运行代码时,我遇到了错误?
代码只是一个使用 direct2d 在窗口上绘制的类。
这是它的样子:
#pragma once
#include <Windows.h>
#include <d2d1.h>
#include <iostream>
#include "LinkedList.h"
class Graphics
{
private:
ID2D1Factory* pFactory;
ID2D1HwndRenderTarget* pRenderTarget;
ID2D1SolidColorBrush* pBrush;
RECT bounds;
float lineWidth = 5.0f;
LinkedList pointList;
public:
Graphics();
~Graphics();
void BeginDraw() { pRenderTarget->BeginDraw(); };
void EndDraw() { pRenderTarget->EndDraw(); };
void SetBrushColor(float r, float g, float b, float a);
void SetBrushColor(float r, float g, float b);
void SetLineWidth(float width);
RECT GetBounds();
void ClearScreen(float r, float g, float b, float a);
void ClearScreen(float r, float g, float b);
void FillCircle(float x, float y, float radius);
void DrawCircle(float x, float y, float radius);
void FillRect(float x, float y, float w, float h);
void DrawRect(float x, float y, float w, float h);
void MoveTo(float x, float y);
void LineTo(float x, float y);
void tester();
bool Init(HWND* pWindowHandle);
};
我得到的错误是这样的:
Error LNK2019 unresolved external symbol _D2D1CreateFactory@16 referenced in function "long __cdecl D2D1CreateFactory(enum D2D1_FACTORY_TYPE,struct _GUID const &,void * *)" (?D2D1CreateFactory@@YAJW4D2D1_FACTORY_TYPE@@ABU_GUID@@PAPAX@Z) ffff c:Userssharkgamingdocumentsvisual studio 2015ProjectsffffffffGraphics.obj 1
起初我以为这是因为我忘记链接到 d2d1.lib,但即使这样做了,我仍然收到错误?
那么,有谁知道为什么我会收到错误以及如何解决它?
好的,在谷歌上搜索了一两个小时后,我发现基本上添加了这个:
#pragma comment(lib,"d2d1.lib")
会解决我的问题。
但是我完全不知道为什么,因为我已经进入了链接器设置并将d2d1.lib添加到其他库文件中?
编辑:天哪,我刚刚想通了。我将库添加到 x64 构建设置而不是 x86 中。 -_-
相关文章:
- 如何在Visual Studio 2019中链接模板库
- C++ 链接器错误 LNK 2019 函数中引用的未解析的外部符号
- 链接另一个文件中的函数时,Qt 上出现错误 LNK 2019
- C++ Direct2D - 从笔记本电脑移动正弦文件后出现链接器错误 2019
- 链接2019简单类C++的错误
- 编程分配的链接错误 2019
- 内联关键字导致可视化C++中链接器错误 2019
- 错误链接 2019
- 链接 Winusb 应用程序和 CUDA 时出现链接器错误 2019
- 路径文件存在导致链接器错误 2028/2019
- 2019链接错误-c++
- 链接器错误2019 C++,VS2008
- 错误链接2019 c++
- 未解决的外部链接2019混乱
- 决策搜索树中的链接错误2019和1120
- c++链接错误2019无法解决的外部符号虚拟错误,因为接口…(?)
- 链接器错误2019而不接触链接器属性
- LNK 2019/1120我的头文件/源文件实践中的双重链接列表错误
- 链接错误 2019,原型在头文件中
- 链接2019错误,但定义存在