When I checked the operation of the test program created with chatgpt using sdl2 and vulkan, the following error occurred. error --------------------------------------- Failed to create SDL window. source code --------------------------------- #include <SDL2/SDL.h> #include <SDL2/SDL_vulkan.h> #include <vulkan/vulkan.h> #include <iostream> #include <stdexcept> #include <cstdlib> #include <vector> const int WIDTH = 800; const int HEIGHT = 600; class VulkanApp { public: void run() { initWindow(); initVulkan(); mainLoop(); cleanup(); } private: SDL_Window* window; VkInstance instance; void initWindow() { if (SDL_Init(SDL_INIT_VIDEO) != 0) { throw std::runtime_error("Failed to initialize SDL."); } window = SDL_CreateWindow("Vulkan Triangle", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, WIDTH, HEIGHT, SDL_WINDOW_VULKAN); if (!window) { throw std::runtime_error("Failed to create SDL window."); } } void initVulkan() { createInstance(); // ここでさらに必要な初期化を行います } void createInstance() { VkApplicationInfo appInfo{}; appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; appInfo.pApplicationName = "Vulkan Triangle"; appInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0); appInfo.pEngineName = "No Engine"; appInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0); appInfo.apiVersion = VK_API_VERSION_1_0; VkInstanceCreateInfo createInfo{}; createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; createInfo.pApplicationInfo = &appInfo; if (vkCreateInstance(&createInfo, nullptr, &instance) != VK_SUCCESS) { throw std::runtime_error("Failed to create Vulkan instance."); } } void mainLoop() { bool quit = false; SDL_Event event; while (!quit) { while (SDL_PollEvent(&event)) { if (event.type == SDL_QUIT) { quit = true; } } } } void cleanup() { vkDestroyInstance(instance, nullptr); SDL_DestroyWindow(window); SDL_Quit(); } }; int main() { VulkanApp app; try { app.run(); } catch (const std::exception& e) { std::cerr << e.what() << std::endl; return EXIT_FAILURE; } return EXIT_SUCCESS; } ------------------------------------------------
Created attachment 252262 [details] patch Could you please try this patch?
Thank you for providing the patch. With this migration to cmake, I tried to see if I could solve the problem myself, but I started relying on you. I'll try this patch when I have time. In the future, I would like to improve my skills and be able to cooperate and contribute to everyone.
Hello, Dmitry.. Thank you for providing this patch. After applying this patch and checking the operation, we were able to confirm that the operation had returned to normal. I will also show you the results of the ldd command.... atsushi@localhost:~/work/program/vulkan/projects/test % ldd ./test ./test: libSDL2-2.0.so.0 => /usr/local/lib/libSDL2-2.0.so.0 (0x1a97b313a000) libvulkan.so.1 => /usr/local/lib/libvulkan.so.1 (0x1a97b35d4000) libc++.so.1 => /lib/libc++.so.1 (0x1a97b4c7c000) libcxxrt.so.1 => /lib/libcxxrt.so.1 (0x1a97b41ed000) libm.so.5 => /lib/libm.so.5 (0x1a97b588b000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x1a97b5d27000) libc.so.7 => /lib/libc.so.7 (0x1a97b6b9a000) libX11.so.6 => /usr/local/lib/libX11.so.6 (0x1a97b8312000) libXext.so.6 => /usr/local/lib/libXext.so.6 (0x1a97b7dc6000) libXcursor.so.1 => /usr/local/lib/libXcursor.so.1 (0x1a97b8e70000) libXi.so.6 => /usr/local/lib/libXi.so.6 (0x1a97b98ee000) libXfixes.so.3 => /usr/local/lib/libXfixes.so.3 (0x1a97b9e99000) libXrandr.so.2 => /usr/local/lib/libXrandr.so.2 (0x1a97ba80b000) libXss.so.1 => /usr/local/lib/libXss.so.1 (0x1a97babaa000) libdrm.so.2 => /usr/local/lib/libdrm.so.2 (0x1a97bbab6000) libgbm.so.1 => /usr/local/lib/libgbm.so.1 (0x1a97bcf25000) libEGL.so.1 => /usr/local/lib/libEGL.so.1 (0x1a97bbd29000) libwayland-egl.so.1 => /usr/local/lib/libwayland-egl.so.1 (0x1a97bc4a2000) libwayland-client.so.0 => /usr/local/lib/libwayland-client.so.0 (0x1a97bcf79000) libwayland-cursor.so.0 => /usr/local/lib/libwayland-cursor.so.0 (0x1a97be7bd000) libxkbcommon.so.0 => /usr/local/lib/libxkbcommon.so.0 (0x1a97bd151000) libinotify.so.0 => /usr/local/lib/libinotify.so.0 (0x1a97bdcac000) libusbhid.so.4 => /usr/lib/libusbhid.so.4 (0x1a97bf6cc000) libthr.so.3 => /lib/libthr.so.3 (0x1a97bf90f000) libxcb.so.1 => /usr/local/lib/libxcb.so.1 (0x1a97c06b4000) libXrender.so.1 => /usr/local/lib/libXrender.so.1 (0x1a97c0e1c000) libwayland-server.so.0 => /usr/local/lib/libwayland-server.so.0 (0x1a97c1c12000) libexpat.so.1 => /usr/local/lib/libexpat.so.1 (0x1a97c201d000) libGLdispatch.so.0 => /usr/local/lib/libGLdispatch.so.0 (0x1a97c2ee4000) libdl.so.1 => /usr/lib/libdl.so.1 (0x1a97c439a000) libepoll-shim.so.0 => /usr/local/lib/libepoll-shim.so.0 (0x1a97c3376000) libffi.so.8 => /usr/local/lib/libffi.so.8 (0x1a97c3b4b000) libXau.so.6 => /usr/local/lib/libXau.so.6 (0x1a97c4d6c000) libXdmcp.so.6 => /usr/local/lib/libXdmcp.so.6 (0x1a97c63c5000) [vdso] (0x1a97b2610000)
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=43c1ea15875dbc5dbc386269b6a0747295741457 commit 43c1ea15875dbc5dbc386269b6a0747295741457 Author: Dmitry Marakasov <amdmi3@FreeBSD.org> AuthorDate: 2024-07-25 11:36:40 +0000 Commit: Dmitry Marakasov <amdmi3@FreeBSD.org> CommitDate: 2024-07-25 11:37:10 +0000 devel/sdl20: fix vulkan support PR: 280278 Reported by: a.hasumoto@gmail.com devel/sdl20/Makefile | 1 + devel/sdl20/files/patch-CMakeLists.txt | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-)
Thanks! I was able to confirm the fix too. Committed. Also, upstream PR: https://github.com/libsdl-org/SDL/pull/10361