Unresolved external symbol
Asked Answered
S

3

6

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.

Stickseed answered 21/7, 2010 at 9:37 Comment(1)
Did you set up the path for the lib files and dll files for the specific include files ?Begird
A
19

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")
Ammeter answered 21/7, 2010 at 9:42 Comment(2)
Fixed for me when I added it just under the include for dwrite.hAnastasia
This also fixed the same error for me (simply adding the #pragma line below the include) in a WinRT C++ component.Megillah
S
1

After adding:

#pragma comment(lib, "dwrite")

this code works.

Stickseed answered 21/7, 2010 at 9:45 Comment(0)
U
1

You have to mention Dwrite.lib in the list of libraries to be linked to your application.

Unveiling answered 21/7, 2010 at 9:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.