Not finding OpenGL support on Ubuntu from fresh build (SDL3)

I am on a relatively fresh Ubuntu 22.04 and have been struggling getting basic SDL3 programs to run. I am working on the SDL/test/testgl.c program right now and I built and installed SDL from the main branch on the GitHub repo from source.

The packages I downloaded:
sudo apt-get install libglew-dev mesa-utils libglu1-mesa-dev mesa-common-dev

The CMake command (from SDL/build directory):

This compiles but it won’t run:
g++ -std=c++11 testgl.c -o testgl -lSDL -lGL

ERROR: No OpenGL support on this system

I can confirm that I have the same issue as you when I try to build it directly using g++. However, it runs just fine when I build it using ( cmake ../SDL -DSDL_TESTS=ON ) from inside my external build directory. (All tests are built in the build directory and put in the folder called test).

It looks like the code expects to be run through cmake, which tests for openGL and defines a variable called HAVE_OPENGL. I don’t really know what else might be going on, but that’s certainly part of the issue.

Thanks @GuildedDoughnut … I did the CMake method, got a different error, and found a tip on Stack Overflow … My nvidia-smi driver was messed up (possibly from installing OpenGL packages?), and I just had to restart my computer.

The SDL OpenGL tests are working!