mickelson / sfml-pi

SFML on Linux without X11 using DRM/KMS (or dispmanx on RPi0-3)
Other
62 stars 26 forks source link

Raspberry pi 4 - sfml example project compilation issues #22

Open TheMaverickProgrammer opened 4 years ago

TheMaverickProgrammer commented 4 years ago

I tried going with the R0-3 build steps first just in case R4 wasn't much different. While it compiled and installed I couldn't build the example programs.

The same for the DRM/KMS version. It would compile and install but no example projects would. Specifically it could not find GLES/gl.h which R4 does not have. Even after installing the recommended packages in the readme and online.

This thread is pretty insightful: https://github.com/raspberrypi/firmware/issues/1171

Other discussions online tend to agree: The “libgles1-mesa-dev” package is no longer available in Debian Buster.

SDL groups struggled with this back in '19: https://discourse.libsdl.org/t/raspberry-pi-4-support-gles-1-1/26350/8

I'm pretty new to pi development but I know SFML without X11 support is exciting because we could port it to other embedded devices. I'm not sure what we can do about this. Is there a way to get sfml-pi running on pi4 with GLES somehow?

mickelson commented 3 years ago

While I haven't tested it very much at all in theory you should be able to compile on a Pi4 with GLES using the following flags in cmake:

cmake .. -DSFML_DRM=1 -DSFML_OPENGL_ES=1

TheMaverickProgrammer commented 3 years ago

The pi 4 seems to have other required dependencies missing

/home/pi/Code/sfml-pi/examples/window/Window.cpp: In function ‘int main()’:
/home/pi/Code/sfml-pi/examples/window/Window.cpp:27:5: error: ‘glClearDepth’ was not declared in this scope
     glClearDepth(1.f);
     ^~~~~~~~~~~~
/home/pi/Code/sfml-pi/examples/window/Window.cpp:27:5: note: suggested alternative: ‘glClearDepthx’
     glClearDepth(1.f);
     ^~~~~~~~~~~~
     glClearDepthx
/home/pi/Code/sfml-pi/examples/window/Window.cpp:45:5: error: ‘glFrustum’ was not declared in this scope
     glFrustum(-ratio, ratio, -1.f, 1.f, 1.f, 500.f);
     ^~~~~~~~~
/home/pi/Code/sfml-pi/examples/window/Window.cpp:45:5: note: suggested alternative: ‘glFrustumx’
     glFrustum(-ratio, ratio, -1.f, 1.f, 1.f, 500.f);
     ^~~~~~~~~
     glFrustumx
TheMaverickProgrammer commented 3 years ago

I managed to successfully build some examples by doing the following:

#define GLdouble double

// change all glFrustrum to glFrustrumx
// change all glClearDepth to glClearDepthx

But the exe won't run because it is missing some linker symbols. The make script stops at shaders example when it fails with the following missing symbols for DRMContext:

[ 94%] Linking CXX executable shader
/usr/bin/ld: ../../lib/libsfml-window.so.2.4.2: undefined reference to `sf::priv::DRMContext::DRMContext(sf::priv::DRMContext*, sf::ContextSettings const&, sf::priv::WindowImpl const*, unsigned int)'
/usr/bin/ld: ../../lib/libsfml-window.so.2.4.2: undefined reference to `sf::priv::DRMContext::DRMContext(sf::priv::DRMContext*, sf::ContextSettings const&, unsigned int, unsigned int)'
/usr/bin/ld: ../../lib/libsfml-window.so.2.4.2: undefined reference to `sf::priv::DRMContext::DRMContext(sf::priv::DRMContext*)'
collect2: error: ld returned 1 exit status
make[2]: *** [examples/window/CMakeFiles/window.dir/build.make:91: examples/window/window] Error 1
make[1]: *** [CMakeFiles/Makefile2:724: examples/window/CMakeFiles/window.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
/usr/bin/ld: ../../lib/libsfml-window.so.2.4.2: undefined reference to `sf::priv::DRMContext::DRMContext(sf::priv::DRMContext*, sf::ContextSettings const&, sf::priv::WindowImpl const*, unsigned int)'
/usr/bin/ld: ../../lib/libsfml-window.so.2.4.2: undefined reference to `sf::priv::DRMContext::DRMContext(sf::priv::DRMContext*, sf::ContextSettings const&, unsigned int, unsigned int)'
/usr/bin/ld: ../../lib/libsfml-window.so.2.4.2: undefined reference to `sf::priv::DRMContext::DRMContext(sf::priv::DRMContext*)'
collect2: error: ld returned 1 exit status
make[2]: *** [examples/shader/CMakeFiles/shader.dir/build.make:92: examples/shader/shader] Error 1
make[1]: *** [CMakeFiles/Makefile2:838: examples/shader/CMakeFiles/shader.dir/all] Error 2
/usr/bin/ld: ../../lib/libsfml-window.so.2.4.2: undefined reference to `sf::priv::DRMContext::DRMContext(sf::priv::DRMContext*, sf::ContextSettings const&, sf::priv::WindowImpl const*, unsigned int)'
/usr/bin/ld: ../../lib/libsfml-window.so.2.4.2: undefined reference to `sf::priv::DRMContext::DRMContext(sf::priv::DRMContext*, sf::ContextSettings const&, unsigned int, unsigned int)'
/usr/bin/ld: ../../lib/libsfml-window.so.2.4.2: undefined reference to `sf::priv::DRMContext::DRMContext(sf::priv::DRMContext*)'
collect2: error: ld returned 1 exit status
make[2]: *** [examples/opengl/CMakeFiles/opengl.dir/build.make:94: examples/opengl/opengl] Error 1
make[1]: *** [CMakeFiles/Makefile2:781: examples/opengl/CMakeFiles/opengl.dir/all] Error 2
[ 95%] Linking CXX executable X11
/usr/bin/ld: ../../lib/libsfml-window.so.2.4.2: undefined reference to `sf::priv::DRMContext::DRMContext(sf::priv::DRMContext*, sf::ContextSettings const&, sf::priv::WindowImpl const*, unsigned int)'
/usr/bin/ld: ../../lib/libsfml-window.so.2.4.2: undefined reference to `sf::priv::DRMContext::DRMContext(sf::priv::DRMContext*, sf::ContextSettings const&, unsigned int, unsigned int)'
/usr/bin/ld: ../../lib/libsfml-window.so.2.4.2: undefined reference to `sf::priv::DRMContext::DRMContext(sf::priv::DRMContext*)'
collect2: error: ld returned 1 exit status
make[2]: *** [examples/X11/CMakeFiles/X11.dir/build.make:95: examples/X11/X11] Error 1
make[1]: *** [CMakeFiles/Makefile2:894: examples/X11/CMakeFiles/X11.dir/all] Error 2