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.
An unresolved symbol is one that you've declared somewhere but never defined. Usually, it means you've #included some third party library's header file but not told the linker where to find the corresponding . obj files for the library.
So when we try to assign it a value in the main function, the linker doesn't find the symbol and may result in an “unresolved external symbol” or “undefined reference”. The way to fix this error is to explicitly scope the variable using '::' outside the main before using it.
The compiler can identify when a symbol isn't declared, but it can't tell when the symbol isn't defined. It's because the definition may be in a different source file or library. If a symbol is referred to but never defined, the linker generates an unresolved external symbol error.
The link-editor's -z defs option can be used to force a fatal error if any undefined symbols remain. This option is recommended when creating any shared objects. Shared objects that reference symbols from an application can use the -z defs option, together with defining the symbols by using an extern mapfile directive.
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
#pragma comment(lib, "Dwrite")
After adding:
#pragma comment(lib, "dwrite")
this code works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With