未解析的外部符号
主要文章有一个头文件 和 源文件。复制这两个文件并添加几个标头后:
#include <Windows.h>
#include <d2d1.h>
#pragma comment(lib, "d2d1")
#include <dwrite.h>
#include <d2d1helper.h>
#include "SafeRelease.h"
//Safe realease file
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)
不知道为什么。全部?包括标题。希望你们中的一些人能够对此提供帮助。
谢谢。
Main article there is a header file and a source file. After copying those two files and adding few headers:
#include <Windows.h>
#include <d2d1.h>
#pragma comment(lib, "d2d1")
#include <dwrite.h>
#include <d2d1helper.h>
#include "SafeRelease.h"
//Safe realease file
template<class Interface>
inline void
SafeRelease(
Interface **ppInterfaceToRelease
)
{
if (*ppInterfaceToRelease != NULL)
{
(*ppInterfaceToRelease)->Release();
(*ppInterfaceToRelease) = NULL;
}
}
when I'm trying to compile this project I'm getting an error:
Error 1 error LNK2019: unresolved external symbol __imp__DWriteCreateFactory@12 referenced in function "private: long __thiscall SimpleText::CreateDeviceIndependentResources(void)" (?CreateDeviceIndependentResources@SimpleText@@AAEJXZ)
Have no idea why. All? headers are included. Hopefuly some of you will be able to help with this.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要链接到 Dwrite.lib,其中包括 DWriteCreateFactory 的实现
请参阅 此处查看文档。底部的要求部分解释了您需要包含和链接到的内容才能使用错误所指的功能。
您可能可以通过添加行来解决此问题
You need to link to Dwrite.lib, which includes the implementation of DWriteCreateFactory
See here for documentation. Requirements section at the bottom explains what you need to include and link to to use the function that the error refers to.
You could probably fix this by adding the line
添加后:
此代码有效。
After adding:
this code works.
您必须在要链接到您的应用程序的库列表中提及 Dwrite.lib。
You have to mention Dwrite.lib in the list of libraries to be linked to your application.