未解析的外部符号

主要文章有一个头文件和一个源文件。复制这两个文件并添加几个标题后:
#include <Windows.h>
#include <d2d1.h>
#pragma comment(lib, "d2d1")
#include <dwrite.h>
#include <d2d1helper.h>
#include "SafeRelease.h"
//安全的重新发布文件
template<class Interface>
inline void
SafeRelease(
    Interface **ppInterfaceToRelease
    )
{
    if (*ppInterfaceToRelease != NULL)
    {
        (*ppInterfaceToRelease)->Release();

        (*ppInterfaceToRelease) = NULL;
    }
}
当我试图编译这个项目时,我收到一个错误: 错误1错误LNK2019:未解析的外部符号__imp__DWriteCreateFactory @ 12在函数“private:long __thiscall SimpleText :: CreateDeviceIndependentResources(void)”中引用(?CreateDeviceIndependentResources @ SimpleText @@ AAEJXZ) 不知道为什么。所有?标题包括在内。希望你们中的一些人能够帮助解决这个问题。 谢谢。     
已邀请:
您需要链接到Dwrite.lib,其中包括DWriteCreateFactory的实现 请参阅此处获取文档底部的“需求”部分说明了需要包含和链接的内容以使用错误引用的功能。 您可以通过添加该行来解决此问题
#pragma comment(lib, "Dwrite")
    
添加后:
#pragma comment(lib, "dwrite")
这段代码有效。     
您必须在要链接到您的应用程序的库列表中提及Dwrite.lib。     

要回复问题请先登录注册