Issue
I am following a Vulkan tutorial and I choose CMake as my build system. However, the build fails every time because it is trying to link with a file called 'vulkan.lib' from what I know, there's no such file as vulkan.lib because the actual library file for Vulkan is 'vulkan-1.lib'
Here is my CMake script:
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})
And here is the build log from 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 ==========
Solution
Thanks to @Stephen Newell's comment I solved it by getting rid of the vulkan
in the second target_link_libraries
call and it worked.
Answered By - SunnyMonster Answer Checked By - Willingham (WPSolving Volunteer)