This README details the steps to compile and execute the C and C++ examples included in this repository, which utilize the X11 library to create basic graphical interfaces.
Ensure the following tools and libraries are installed on your system before starting:
- CMake (version 3.0 or higher)
- A C and C++ compiler (such as GCC or Clang)
- The X11 development libraries
- Python (optional, for using the provided script to automate building and running)
-
Create and navigate to a new build directory:
mkdir build && cd build
-
Execute CMake to configure and build the project:
cmake .. && make example_c
-
Run the compiled C example:
./example_c
-
If not already in the
build
directory, create it and navigate there:mkdir build && cd build
-
Configure and build the C++ example using CMake:
cmake .. && make example_cpp
-
Execute the compiled C++ program:
./example_cpp
The run.py
script simplifies the process of building and running the examples.
-
Verify Python is installed on your system.
-
Execute the script specifying the example type (
c
for C orcpp
for C++):python run.py type=c
or
python run.py type=cpp
The script will clean up any previous build, compile the chosen example, and run the resulting binary.
- Confirm that the X11 development libraries are installed properly on your machine. The package is typically named
libx11-dev
or something similar, depending on your OS. - While the Python script offers a convenient way to build and run the examples, you can manually compile and execute them using CMake and your preferred build system.
For any issues, ensure your setup is appropriate for X11 development and all necessary dependencies are in place.