This repository has been archived on 2022-12-28. You can view files and clone it, but cannot push or open issues or pull requests.
site-posts/SDL2 on Rpi without X11.html

35 lines
1.1 KiB
HTML
Raw Permalink Normal View History

2022-12-27 00:22:00 +00:00
<div>
<div>
<p>If you want to do graphical applications with SDL2 on a rapsberry pi
without the overhead of X11, you will need to compile SDL2 yourself. I'll
assume you are running raspian.</p>
<p>Install required libraries to build</p>
<blockquote class="code-block">sudo apt-get install libdrm-dev libgdm-dev</blockquote>
<p>Next download a SDL2 source tarball. They can be found <a
href="https://www.libsdl.org/download-2.0.php">here</a>.
Next, change to the directory of the unzipped tarball and run the following.</p>
<blockquote class="code-block">./configure --enable-video=kmsdrm
make -j4
sudo make install
</blockquote>
<p>To check if the library was compiled sucessfully, compile <a
href="https://pastebin.com/raw/5gQXZ2mZ">this</a>
piece of code. You should see the screen flashing, as well as your desired
graphics driver on stdout. To compile,</p>
<blockquote class="code-block">g++ ./test_prog.cpp `pkg-config --cflags --libs sdl2`
</blockquote>
<p>You can change the driver used via raspi-config if opengl es is not
desired.</p>
<p>I hope this helped someone, happy embedded programming!</p>
</div>
</div>