cannot find -ld3d12
-
I am trying to run a project that I just opened on Windows 10 using cmake and I have not made any changes to it. When I press the build project button, I get the error below. Linker seems to find d3d11 but not d3d12.
15:41:08: Running steps for project c... 15:41:09: Starting: "C:\Qt\Tools\CMake_64\bin\cmake.exe" --build C:/Users/User/Desktop/build-c-Desktop-Debug --target all [1/1 2.6/sec] Linking CXX executable c.exe FAILED: c.exe cmd.exe /C "cd . && C:\PROGRA~1\MINGW-~1\X86_64~1.0-P\mingw64\bin\G__~1.EXE -DQT_QML_DEBUG -g -mwindows CMakeFiles/c.dir/c_autogen/mocs_compilation.cpp.obj CMakeFiles/c.dir/main.cpp.obj CMakeFiles/c.dir/mainwindow.cpp.obj -o c.exe -Wl,--out-implib,libc.dll.a -Wl,--major-image-version,0,--minor-image-version,0 C:/Qt/6.6.1/mingw_64/lib/libQt6Widgets.a C:/Qt/6.6.1/mingw_64/lib/libQt6Gui.a C:/Qt/6.6.1/mingw_64/lib/libQt6Core.a -lmpr -luserenv -lmingw32 C:/Qt/6.6.1/mingw_64/lib/libQt6EntryPoint.a -lshell32 -ld3d11 -ldxgi -ldxguid -ld3d12 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ." C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -ld3d12 collect2.exe: error: ld returned 1 exit status ninja: build stopped: subcommand failed. 15:41:09: The process "C:\Qt\Tools\CMake_64\bin\cmake.exe" exited with code 1. Error while building/deploying project c (kit: Desktop) When executing step "Build" 15:41:09: Elapsed time: 00:01.
I get the same error when I put the full path of d3d12, dxgi and d3dcompiler in the CMakeLists.txt file. I am sure the path is correct. How can I fix this?
target_link_libraries(c PRIVATE "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.22621.0/um/x64/d3d12.lib" "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.22621.0/um/x64/dxgi.lib" "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.22621.0/um/x64/d3dcompiler.lib" Qt${QT_VERSION_MAJOR}::Widgets )
I tried this first and also didn't work
target_link_libraries(c PRIVATE d3d12 Qt${QT_VERSION_MAJOR}::Widgets )
-
I am trying to run a project that I just opened on Windows 10 using cmake and I have not made any changes to it. When I press the build project button, I get the error below. Linker seems to find d3d11 but not d3d12.
15:41:08: Running steps for project c... 15:41:09: Starting: "C:\Qt\Tools\CMake_64\bin\cmake.exe" --build C:/Users/User/Desktop/build-c-Desktop-Debug --target all [1/1 2.6/sec] Linking CXX executable c.exe FAILED: c.exe cmd.exe /C "cd . && C:\PROGRA~1\MINGW-~1\X86_64~1.0-P\mingw64\bin\G__~1.EXE -DQT_QML_DEBUG -g -mwindows CMakeFiles/c.dir/c_autogen/mocs_compilation.cpp.obj CMakeFiles/c.dir/main.cpp.obj CMakeFiles/c.dir/mainwindow.cpp.obj -o c.exe -Wl,--out-implib,libc.dll.a -Wl,--major-image-version,0,--minor-image-version,0 C:/Qt/6.6.1/mingw_64/lib/libQt6Widgets.a C:/Qt/6.6.1/mingw_64/lib/libQt6Gui.a C:/Qt/6.6.1/mingw_64/lib/libQt6Core.a -lmpr -luserenv -lmingw32 C:/Qt/6.6.1/mingw_64/lib/libQt6EntryPoint.a -lshell32 -ld3d11 -ldxgi -ldxguid -ld3d12 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ." C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -ld3d12 collect2.exe: error: ld returned 1 exit status ninja: build stopped: subcommand failed. 15:41:09: The process "C:\Qt\Tools\CMake_64\bin\cmake.exe" exited with code 1. Error while building/deploying project c (kit: Desktop) When executing step "Build" 15:41:09: Elapsed time: 00:01.
I get the same error when I put the full path of d3d12, dxgi and d3dcompiler in the CMakeLists.txt file. I am sure the path is correct. How can I fix this?
target_link_libraries(c PRIVATE "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.22621.0/um/x64/d3d12.lib" "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.22621.0/um/x64/dxgi.lib" "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.22621.0/um/x64/d3dcompiler.lib" Qt${QT_VERSION_MAJOR}::Widgets )
I tried this first and also didn't work
target_link_libraries(c PRIVATE d3d12 Qt${QT_VERSION_MAJOR}::Widgets )
You have to link against MinGW import libs, not MSVC ones. You can not mix them.
-
You have to link against MinGW import libs, not MSVC ones. You can not mix them.
@Christian-Ehrlicher Thank you, I installed MSVC and everything is working now but I wonder, Is the official version of these libraries for MinGW available?
-
@Christian-Ehrlicher Thank you, I installed MSVC and everything is working now but I wonder, Is the official version of these libraries for MinGW available?
@pistachio MingW is supposed to have included DirectX 12 headers/libraries since version 8.0. Perhaps an upgrade is needed.
Do relevant files exist within your MingW install (even though CMake does not find them) ?