For some reason the linker was not searching d2d1.lib which caused the LNK2019 error. If you add d2d1.lib to the linker inputs in the project property page instead of using the pragma directive it will build successfully.
Why do I get this error when I run my project as a .DLL but not as a .EXE
I've got a .dll project in which I'm utilizing Direct 2D to draw on a window. For some reason, one line is continually giving me errors when I attempt to run it:
// Create a Direct2D factory.
hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &m_pDirect2dFactory);
The problem is that this line works fine when I run the project as a .exe. I copied and pasted the whole page over from the working project to the new .dll but it now gives me this error:
Severity Code Description Project File Line Suppression State Details Error LNK2019 unresolved external symbol D2D1CreateFactory referenced in function "long __cdecl D2D1CreateFactory(enum D2D1_FACTORY_TYPE,struct _GUID const &,void * *)" (?D2D1CreateFactory@@YAJW4D2D1_FACTORY_TYPE@@AEBU_GUID@@PEAPEAX@Z) DxfDrawer C:\Users\REDACTED\source\repos\Direct2DinWPF\DxfDrawer\DxfDrawer.obj 1
Here is a link to my project. The line in question is line 126.