CMake 尝试 link 与 'vulkan.lib'
CMake trying to link with 'vulkan.lib'
我正在学习 Vulkan 教程并选择 CMake 作为我的构建系统。但是,每次构建都会失败,因为它试图 link 一个名为 'vulkan.lib' 的文件,据我所知,没有 vulkan.lib 这样的文件,因为 Vulkan 的实际库文件是 'vulkan-1.lib'
这是我的 CMake 脚本:
project(VulkanTutorial)
set(CMAKE_CXX_STANDARD 20)
add_executable(VulkanTutorial main.cpp VulkanWindow.cpp VulkanWindow.h FirstApp.h)
add_subdirectory(deps/glfw-3.3.6)
find_package(Vulkan REQUIRED)
include_directories(deps/glfw-3.3.6/include, ${Vulkan_INCLUDE_DIRS})
target_link_libraries(VulkanTutorial glfw ${GLFW_LIBRARIES})
target_link_libraries(VulkanTutorial vulkan ${Vulkan_LIBRARIES})
这是来自 Visual Studio 的构建日志:
Build started...
1>------ Build started: Project: ZERO_CHECK, Configuration: Debug x64 ------
1>Checking Build System
2>------ Build started: Project: glfw, Configuration: Debug x64 ------
2>Building Custom Rule C:/dev/c++/VulkanTutorial (Cmake)/deps/glfw-3.3.6/src/CMakeLists.txt
2>context.c
2>init.c
2>input.c
2>monitor.c
2>vulkan.c
2>window.c
2>win32_init.c
2>win32_joystick.c
2>win32_monitor.c
2>win32_time.c
2>win32_thread.c
2>win32_window.c
2>wgl_context.c
2>egl_context.c
2>osmesa_context.c
2>Generating Code...
2>glfw.vcxproj -> C:\dev\c++\VulkanTutorial (Cmake)\deps\glfw-3.3.6\src\Debug\glfw3.lib
3>------ Build started: Project: VulkanTutorial, Configuration: Debug x64 ------
3>Building Custom Rule C:/dev/c++/VulkanTutorial (Cmake)/CMakeLists.txt
3>main.cpp
3>VulkanWindow.cpp
3>Generating Code...
3>LINK : fatal error LNK1104: cannot open file 'vulkan.lib'
3>Done building project "VulkanTutorial.vcxproj" -- FAILED.
========== Build: 2 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
感谢@Stephen Newell 的评论,我通过在第二个 target_link_libraries
调用中删除 vulkan
解决了这个问题,并且成功了。
我正在学习 Vulkan 教程并选择 CMake 作为我的构建系统。但是,每次构建都会失败,因为它试图 link 一个名为 'vulkan.lib' 的文件,据我所知,没有 vulkan.lib 这样的文件,因为 Vulkan 的实际库文件是 'vulkan-1.lib'
这是我的 CMake 脚本:
project(VulkanTutorial)
set(CMAKE_CXX_STANDARD 20)
add_executable(VulkanTutorial main.cpp VulkanWindow.cpp VulkanWindow.h FirstApp.h)
add_subdirectory(deps/glfw-3.3.6)
find_package(Vulkan REQUIRED)
include_directories(deps/glfw-3.3.6/include, ${Vulkan_INCLUDE_DIRS})
target_link_libraries(VulkanTutorial glfw ${GLFW_LIBRARIES})
target_link_libraries(VulkanTutorial vulkan ${Vulkan_LIBRARIES})
这是来自 Visual Studio 的构建日志:
Build started...
1>------ Build started: Project: ZERO_CHECK, Configuration: Debug x64 ------
1>Checking Build System
2>------ Build started: Project: glfw, Configuration: Debug x64 ------
2>Building Custom Rule C:/dev/c++/VulkanTutorial (Cmake)/deps/glfw-3.3.6/src/CMakeLists.txt
2>context.c
2>init.c
2>input.c
2>monitor.c
2>vulkan.c
2>window.c
2>win32_init.c
2>win32_joystick.c
2>win32_monitor.c
2>win32_time.c
2>win32_thread.c
2>win32_window.c
2>wgl_context.c
2>egl_context.c
2>osmesa_context.c
2>Generating Code...
2>glfw.vcxproj -> C:\dev\c++\VulkanTutorial (Cmake)\deps\glfw-3.3.6\src\Debug\glfw3.lib
3>------ Build started: Project: VulkanTutorial, Configuration: Debug x64 ------
3>Building Custom Rule C:/dev/c++/VulkanTutorial (Cmake)/CMakeLists.txt
3>main.cpp
3>VulkanWindow.cpp
3>Generating Code...
3>LINK : fatal error LNK1104: cannot open file 'vulkan.lib'
3>Done building project "VulkanTutorial.vcxproj" -- FAILED.
========== Build: 2 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
感谢@Stephen Newell 的评论,我通过在第二个 target_link_libraries
调用中删除 vulkan
解决了这个问题,并且成功了。