OpenCL-Headers-2025.07.22

#### Gaming Linux® From Scratch - Version 13.0

### Chapter 10. Graphics APIs

- Prev

  DRI from Mesa-25.3.5

- Next

  OCL-ICD-2.3.4

- Up
- Home

# OpenCL-Headers-2025.07.22

## Introduction to OpenCL-Headers

This page covers the installation of the C and C++ headers of the OpenCL API, which allows running functions, or kernels, on CPUs and GPUs. This can speed up certain actions, allowing for better performance.

### OpenCL-Headers Dependencies

Required
CMake-4.2.3
Optional
Doxygen, Graphviz, and Ruby-4.0.1

## Downloading OpenCL-Headers

First, create a list of files to be downloaded:

    cat > ocl-headers-list << "EOF"
    OpenCL-Headers/archive/v2025.07.22/OpenCL-Headers-2025.07.22.tar.gz
    OpenCL-CLHPP/archive/v2025.07.22/OpenCL-CLHPP-2025.07.22.tar.gz
    EOF

To download the needed files using Wget-1.25.0, use the following commands:

    mkdir ocl-headers &&
    cd    ocl-headers &&
    grep -v '^#' ../ocl-headers-list | wget -i- -c \
        -B https://github.com/KhronosGroup/

## Installation of OpenCL-Headers

### Note

When installing multiple packages in a script, the installation needs to be done as the root user. There are three general options that can be used to do this:

1. Run the entire script as the root user (not recommended).

2. Use the sudo command from the sudo package.

3. Use su -c "command arguments" (quotes required) which will ask for the root password for every iteration of the loop.

One way to handle this situation is to create a short bash function that automatically selects the appropriate method. Once the command is set in the environment, it does not need to be set again.

    as_root()
    {
      if   [ $EUID = 0 ];        then $*
      elif [ -x /usr/bin/sudo ]; then sudo $*
      else                            su -c \\"$*\\"
      fi
    }

    export -f as_root

First, start a subshell that will exit on error:

    bash -e

Install all of the packages by running the following commands:

    for package in OpenCL-{Headers,CLHPP}
    do
      longpackage=$package-2025.07.22.tar.?z*
      packagedir=${longpackage%.tar.?z*}
      tar -xf $longpackage
      pushd $packagedir
        mkdir build
        cd    build
        cmake -D CMAKE_INSTALL_PREFIX=/usr \
              -D CMAKE_BUILD_TYPE=Release  \
              -D BUILD_TESTING=OFF         \
              -D BUILD_EXAMPLES=OFF        \
              -G Ninja ..
        as_root ninja install
      popd
      rm -rf $packagedir
    done

Finally, exit the shell that was started earlier:

    exit

## Contents

Installed Programs: None
Installed Libraries: None
Installed Directories: /usr/include/CL and /usr/share/cmake/OpenCLHeaders{,Cpp}

- Prev

  DRI from Mesa-25.3.5

- Next

  OCL-ICD-2.3.4

- Up
- Home