Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/DREssedAlarm184/LWXGL/llms.txt

Use this file to discover all available pages before exploring further.

LWXGL is distributed as source code and must be compiled into a shared library (libLWXGL.so) before use. The build process is a single make invocation that produces the library from src/main.cc using g++. Installation copies the library and its public header to the standard system locations so that any C or C++ project on the machine can link against it.

Prerequisites

You need g++ (GCC C++ compiler), the Xlib development headers, and a running X11 display on the build machine. The exact package name for the Xlib headers differs by distribution:
  • Debian / Ubuntu: libx11-dev
  • Fedora / RHEL: libX11-devel
Install the required packages for your distribution:
# Debian / Ubuntu
sudo apt-get install build-essential libx11-dev

# Fedora / RHEL
sudo dnf install gcc-c++ libX11-devel

Build

From the root of the LWXGL source tree, run:
make build
This executes the following command internally:
g++ -fPIC -shared -O2 -o libLWXGL.so src/main.cc -lX11 -fvisibility=hidden
  • -fPIC and -shared produce position-independent code suitable for a shared library.
  • -O2 enables standard optimizations.
  • -fvisibility=hidden ensures only symbols explicitly marked for export are visible in the resulting .so, keeping the public surface clean.
On success, libLWXGL.so appears in the current directory.

Install

Copy the library and its header to system-wide locations:
sudo make install
This runs three steps:
  1. Copies libLWXGL.so to /usr/local/lib.
  2. Copies src/libLWXGL.h to /usr/local/include.
  3. Runs ldconfig to rebuild the dynamic linker cache so the new library is immediately discoverable by the runtime linker.

Verify

Confirm that the dynamic linker cache recognises the installed library:
ldconfig -p | grep LWXGL
You should see a line such as:
libLWXGL.so (libc6,x86-64) => /usr/local/lib/libLWXGL.so
If the command produces no output, see the tip below.
If the runtime linker cannot find libLWXGL.so after installation (e.g. you see a “cannot open shared object file” error when running your program), add /usr/local/lib to your library search path and retry:
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
To make the change permanent, add that line to your shell profile (e.g. ~/.bashrc or ~/.profile), or create a file under /etc/ld.so.conf.d/ containing /usr/local/lib and run sudo ldconfig again.

Using in your project

Once installed, compile any C or C++ source file against LWXGL by adding -lLWXGL to your compiler invocation:
# C
gcc my_app.c -lLWXGL -lX11 -o my_app

# C++
g++ my_app.cc -lLWXGL -lX11 -o my_app
The -lX11 flag is included explicitly here as a safety measure. Although libLWXGL.so itself was linked against libX11 at build time, making the transitive dependency available to the linker, specifying -lX11 directly avoids potential link-order issues on systems with strict symbol resolution.

Build docs developers (and LLMs) love