Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix example_win32_directx11 linker settings. #2327

Conversation

tom-seddon
Copy link
Contributor

Got an error building example_win32_directx11 from the repo, using Visual Studio 2017, compiler version Microsoft (R) C/C++ Optimizing Compiler Version 19.16.27023.1 for x86.

Running build_win32.bat I get this command line:

cl /nologo /Zi /MD /I .. /I ..\.. /I "C:\Program Files (x86)\Windows Kits\10\Include\um" /I "C:\Program Files (x86)\Windows Kits\10\Include\shared" /I "Include" /D UNICODE /D _UNICODE *.cpp ..\imgui_impl_dx11.cpp ..\imgui_impl_win32.cpp ..\..\imgui*.cpp /FeDebug/example_win32_directx11.exe /FoDebug/ /link /LIBPATH:"/Lib/x86" d3d11.lib d3dcompiler.lib

And this error:

imgui_impl_win32.obj : error LNK2019: unresolved external symbol __imp__GetDeviceCaps@8 referenced in function "float __cdecl ImGui_ImplWin32_GetDpiScaleForMonitor(void *)" (?ImGui_ImplWin32_GetDpiScaleForMonitor@@YAMPAX@Z)
Debug/example_win32_directx11.exe : fatal error LNK1120: 1 unresolved externals

The fix for me was to add gdi32.lib to the command line explicitly.

Thanks,

--Tom

@ocornut
Copy link
Owner

ocornut commented Feb 1, 2019

Hello @tom-seddon,

I noted this only happens in the docking branch, due to the presence of ImGui_ImplWin32_GetDpiScaleForMonitor() calling GetDeviceCaps(), and this affect all the examples using imgui_impl_win32.cpp (not only the DX11 one).

I added the extra gdi32.lib linkage request through pragma, as commonly/conventially allowed by Visual Studio compiler.

@ocornut ocornut closed this Feb 1, 2019
@ice1000
Copy link
Contributor

ice1000 commented Feb 11, 2019

Hi, the unresolved reference still happens to me. Applying this PR fixes the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants