繁体   English   中英

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:\Users\sharkgaming\documents\visual studio 2015\Projects\ffff\ffff\Graphics.obj   1   

起初我以为是因为我忘记了链接到d2d1.lib的原因,但是即使这样做,我仍然会收到错误消息?

那么,有谁知道我为什么得到此错误以及如何解决它?

好吧,在谷歌搜索了一两个小时之后,我发现基本上是这样添加的:

#pragma comment(lib,"d2d1.lib")

会解决我的问题。

但是我完全不知道为什么,因为我已经进入链接器设置并将d2d1.lib添加到其他库文件中了?

编辑:天哪,我只是想通了。 我将库添加到x64构建设置中,而不是x86。 -_-

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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