Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDL2 not defined by default on linux #920

Open
tonitch opened this issue Aug 11, 2024 · 2 comments
Open

SDL2 not defined by default on linux #920

tonitch opened this issue Aug 11, 2024 · 2 comments

Comments

@tonitch
Copy link

tonitch commented Aug 11, 2024

System

Archlinux x64

Problem

SDL2 is not defined by default.

#ifdef SDL2
#include <SDL2/SDL.h>
#include <SDL_vulkan.h>
#include "sdl2.h"
#endif

SDL2 is then never included and compilation is not possible

step to reproduce

With the simpliest program and compilation:

#include <WickedEngine/WickedEngine.h>

int main()
{
	return 0;
}
$ g++ main.cpp                                                                                                                                                 [130]
In file included from /usr/include/WickedEngine/wiApplication.h:3,
                 from /usr/include/WickedEngine/WickedEngine.h:13,
                 from main.cpp:1:
/usr/include/WickedEngine/wiPlatform.h: In function ‘void wi::platform::GetWindowProperties(window_type, WindowProperties*)’:
/usr/include/WickedEngine/wiPlatform.h:87:17: error: ‘SDL_GetWindowSize’ was not declared in this scope
   87 |                 SDL_GetWindowSize(window, &window_width, &window_height);
      |                 ^~~~~~~~~~~~~~~~~
/usr/include/WickedEngine/wiPlatform.h:88:17: error: ‘SDL_Vulkan_GetDrawableSize’ was not declared in this scope
   88 |                 SDL_Vulkan_GetDrawableSize(window, &dest->width, &dest->height);

I don't like cmake that much but I tried to compile the linux_template and got the same error.

Solution

I think Line 33 should be checking PLATFORM_LINUX or SDL2 Should be set before hand on linux plateform.

Workaround and problem #2

I compile using $ g++ main.cpp -DSDL2 and got

In file included from /usr/include/WickedEngine/wiApplication.h:3,
                 from /usr/include/WickedEngine/WickedEngine.h:13,
                 from main.cpp:1:
/usr/include/WickedEngine/wiPlatform.h:35:10: fatal error: SDL_vulkan.h: No such file or directory
   35 | #include <SDL_vulkan.h>
      |

Solution

line 35 should be #include <SDL2/SDL_vulkan.h>

Conclusion

I could make a pr about that but I just discovered the project and I would like your input on that. maybe I'm just missing something but this feels like a tiny bug more than anything to me ^^

@brakhane
Copy link
Contributor

line 35 should be #include <SDL2/SDL_vulkan.h>

Both should work, but since we're using <SDL2/SDL.h> in the line above, and also use <SDL2/SDL_vulkan.h> in wiGraphicsDevice_Vulkan.cpp, I think that's a good change (you should also update imgui_impl_sdl.cpp)

I don't like cmake that much but I tried to compile the linux_template and got the same error.

How did you compile the linux_template? I compiled it around 2 days ago in an arch chroot and it worked out of the box.

@tonitch
Copy link
Author

tonitch commented Aug 11, 2024

$ git clone git@github.com:turanszkij/WickedEngine
$ cd WickedEngine/Template_Linux
$ cmake -S . -B build
$ cmake --build build -j 12
[ 50%] Building CXX object CMakeFiles/Template_Linux.dir/main.cpp.o
In file included from /home/tonitch/WickedEngine/Template_Linux/main.cpp:1:
/home/tonitch/WickedEngine/Template_Linux/stdafx.h:2:10: fatal error: WickedEngine.h: No such file or directory
    2 | #include "WickedEngine.h"
      |          ^~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/Template_Linux.dir/build.make:76: CMakeFiles/Template_Linux.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/Template_Linux.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

as I installed wickedengine on my system using the aur I made myself so error is expected
I put #include "WickedEngine/WickedEngine.h" in stdafx.h

$ cmake --build build -j 12                                                                                                                                           ±[●][master]
[ 50%] Building CXX object CMakeFiles/Template_Linux.dir/main.cpp.o
In file included from /usr/include/WickedEngine/wiApplication.h:3,
                 from /usr/include/WickedEngine/WickedEngine.h:13,
                 from /home/tonitch/WickedEngine/Template_Linux/stdafx.h:2,
                 from /home/tonitch/WickedEngine/Template_Linux/main.cpp:1:
/usr/include/WickedEngine/wiPlatform.h: In function ‘void wi::platform::GetWindowProperties(window_type, WindowProperties*)’:
/usr/include/WickedEngine/wiPlatform.h:87:17: error: ‘SDL_GetWindowSize’ was not declared in this scope
   87 |                 SDL_GetWindowSize(window, &window_width, &window_height);
      |                 ^~~~~~~~~~~~~~~~~
/usr/include/WickedEngine/wiPlatform.h:88:17: error: ‘SDL_Vulkan_GetDrawableSize’ was not declared in this scope
   88 |                 SDL_Vulkan_GetDrawableSize(window, &dest->width, &dest->height);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/tonitch/WickedEngine/Template_Linux/main.cpp: In function ‘int main(int, char**)’:
/home/tonitch/WickedEngine/Template_Linux/main.cpp:55:5: error: ‘sdl2’ has not been declared
   55 |     sdl2::sdlsystem_ptr_t system = sdl2::make_sdlsystem(SDL_INIT_EVERYTHING | SDL_INIT_EVENTS);
      |     ^~~~
/home/tonitch/WickedEngine/Template_Linux/main.cpp:56:5: error: ‘sdl2’ has not been declared
   56 |     sdl2::window_ptr_t window = sdl2::make_window(
      |     ^~~~
/home/tonitch/WickedEngine/Template_Linux/main.cpp:64:27: error: ‘window’ was not declared in this scope
   64 |     application.SetWindow(window.get());
      |                           ^~~~~~
make[2]: *** [CMakeFiles/Template_Linux.dir/build.make:76: CMakeFiles/Template_Linux.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/Template_Linux.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants