I'm setting up my programming environment in VSCode, and coming from VS where everything is automated (mostly), I'm finding that CMake is giving me an exceptional amount of trouble. I'm attempting to setup SDL2 by using the libraries that came with the VulkanSDK, but I'm getting linker error upon linker error. I've spent the last three or four days scouring the internet, with none of the solutions that are present on Stack Overflow or any other medium having worked.
Here is my CMakeLists.txt
cmake_minimum_required(VERSION 3.0.0)
project(P2_PR VERSION 0.1.0)
add_executable(P2_PR main.cpp)
find_package(Vulkan QUIET)
if(NOT Vulkan_FOUND)
message(FATAL_ERROR "Vulkan not found. Download at
https://www.vulkan.org/")
endif()
include_directories(${Vulkan_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${Vulkan_LIBRARIES}
${SDL2_LIBRARIES} ${GLM_LIBRARIES})
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20)
It is successfully locating the directories, and I am able to include the libs without issue. No squiggly line, no "can't find .h". It seems to be exclusively a linker issue, and I fear that my lack of CMake experience is making deciphering the problem impossible.
Not every SDL reference is complained about. For instance; I am able to create a window pointer using the SDL_Window reference, however the use of any SDL-specific functions return an error.
This works:
int main(int argc, char** argv) {
SDL_Window* window;
return 0;
}
This does not work, and returns the error Undefined Reference to: SDL_PollEvent
:
int main(int argc, char** argv) {
SDL_Window* window;
SDL_PollEvent(nullptr);
return 0;
}
I can confirm that vulkan and GLM both work properly. It's simply SDL2 giving me the trouble. I would greatly appreciate any help anyone here has to offer.