New to CMake, could use some help building hello_xr

I’ve cloned the whole https://github.com/KhronosGroup/OpenXR-SDK-Source repository to my desktop, and have run cmake (using “Visual Studio 16 2019”) generating the OPENXR.sln. Opening that solution, I right click on it and hit “build”. There were a whole lot of successes, and a couple failures. Mostly linker errors that appear to be referring to D3D.

So, is there some step I should be doing to explicitly link D3D? Or was cmake supposed to take care of that? What else do I need to do?

1>------ Build started: Project: generate_openxr_header, Configuration: Debug x64 ------
2>------ Build started: Project: xr_global_generated_files, Configuration: Debug x64 ------
3>------ Build started: Project: generated_layer_json_files, Configuration: Debug x64 ------
4>------ Build started: Project: run_hello_xr_glsl_compiles, Configuration: Debug x64 ------
5>------ Build started: Project: copy-api_dump-def-file, Configuration: Debug x64 ------
6>------ Build started: Project: copy-core_validation-def-file, Configuration: Debug x64 ------
7>------ Build started: Project: copy-test-def-file, Configuration: Debug x64 ------
8>------ Build started: Project: copy-test_runtime-def-file, Configuration: Debug x64 ------
9>------ Skipped Build: Project: uninstall, Configuration: Debug x64 ------
9>Project not selected to build for this solution configuration 
10>------ Build started: Project: hello_xr, Configuration: Debug x64 ------
11>------ Build started: Project: loader_test, Configuration: Debug x64 ------
11>loader_test.obj : error LNK2019: unresolved external symbol D3D11CreateDevice referenced in function "void __cdecl TestCreateDestroySession(unsigned int &,unsigned int &,unsigned int &,unsigned int &)" (?TestCreateDestroySession@@YAXAEAI000@Z)
11>C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\um\x86\d3d11.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
11>C:\Users\phildo\Desktop\oxr-src-build\build\win64\src\tests\loader_test\Debug\loader_test.exe : fatal error LNK1120: 1 unresolved externals
10>d3d_common.obj : error LNK2019: unresolved external symbol CreateDXGIFactory1 referenced in function "class Microsoft::WRL::ComPtr<struct IDXGIAdapter1> __cdecl GetAdapter(struct _LUID)" (?GetAdapter@@YA?AV?$ComPtr@UIDXGIAdapter1@@@WRL@Microsoft@@U_LUID@@@Z)
10>d3d_common.obj : error LNK2019: unresolved external symbol D3DCompile referenced in function "class Microsoft::WRL::ComPtr<struct ID3D10Blob> __cdecl CompileShader(char const *,char const *,char const *)" (?CompileShader@@YA?AV?$ComPtr@UID3D10Blob@@@WRL@Microsoft@@PEBD00@Z)
10>graphicsplugin_d3d11.obj : error LNK2019: unresolved external symbol D3D11CreateDevice referenced in function "void __cdecl `anonymous namespace'::InitializeD3D11DeviceForAdapter(struct IDXGIAdapter1 *,class std::vector<enum D3D_FEATURE_LEVEL,class std::allocator<enum D3D_FEATURE_LEVEL> > const &,struct ID3D11Device * *,struct ID3D11DeviceContext * *)" (?InitializeD3D11DeviceForAdapter@?A0xdfe2e81b@@YAXPEAUIDXGIAdapter1@@AEBV?$vector@W4D3D_FEATURE_LEVEL@@V?$allocator@W4D3D_FEATURE_LEVEL@@@std@@@std@@PEAPEAUID3D11Device@@PEAPEAUID3D11DeviceContext@@@Z)
10>graphicsplugin_d3d12.obj : error LNK2019: unresolved external symbol D3D12SerializeRootSignature referenced in function "public: void __cdecl `anonymous namespace'::D3D12GraphicsPlugin::InitializeResources(void)" (?InitializeResources@D3D12GraphicsPlugin@?A0x59769ab5@@QEAAXXZ)
10>graphicsplugin_d3d12.obj : error LNK2019: unresolved external symbol D3D12CreateDevice referenced in function "void __cdecl `anonymous namespace'::InitializeD3D12DeviceForAdapter(struct IDXGIAdapter1 *,enum D3D_FEATURE_LEVEL,struct ID3D12Device * *)" (?InitializeD3D12DeviceForAdapter@?A0x59769ab5@@YAXPEAUIDXGIAdapter1@@W4D3D_FEATURE_LEVEL@@PEAPEAUID3D12Device@@@Z)
10>graphicsplugin_d3d12.obj : error LNK2019: unresolved external symbol D3D12GetDebugInterface referenced in function "void __cdecl `anonymous namespace'::InitializeD3D12DeviceForAdapter(struct IDXGIAdapter1 *,enum D3D_FEATURE_LEVEL,struct ID3D12Device * *)" (?InitializeD3D12DeviceForAdapter@?A0x59769ab5@@YAXPEAUIDXGIAdapter1@@W4D3D_FEATURE_LEVEL@@PEAPEAUID3D12Device@@@Z)
10>C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\um\x86\d3d11.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
10>C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\um\x86\dxgi.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
10>C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\um\x86\d3dcompiler.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
11>Done building project "loader_test.vcxproj" -- FAILED.
10>C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\um\x86\d3d12.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
10>C:\Users\phildo\Desktop\oxr-src-build\build\win64\src\tests\hello_xr\Debug\hello_xr.exe : fatal error LNK1120: 6 unresolved externals
10>Done building project "hello_xr.vcxproj" -- FAILED.
12>------ Skipped Build: Project: INSTALL, Configuration: Debug x64 ------
12>Project not selected to build for this solution configuration 
========== Build: 8 succeeded, 2 failed, 9 up-to-date, 2 skipped ==========

Hmm, it should work with no trouble - when did you clone it? There were some CMake bugs in 1.0.9, but 1.0.10 was recently released which included fixes for them. You’ll need to clear your build directory. I think that’s the problem here - CMake picked up the 32-bit libraries when building the 64-bit project.

In addition, I’d recommend building as RelWithDebInfo, rather than full Debug.

Make sure (in the Visual Studio Installer) that you are fully up to date and have the Windows Kits fully installed for all the platforms you want to build for.

looks like you don’t have d3dx lib on your computer.

install D3DX SDK should work.

I don’t think you want to install D3DX. That’s outdated and definitely not needed - I did not need to install it for CI to build. The actual answer was buried in my post - this is a “mix of architectures” problem.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.