DEV Community

vast cow
vast cow

Posted on

Building llama.cpp in an Environment Without curl Headers

When you try to build llama.cpp on a system where the curl development headers are not installed, the build may fail because the compiler cannot find curl’s header files (such as curl/curl.h). One straightforward workaround is to download the matching curl source package (so you have the headers locally) and then point CMake to the existing curl library on your system plus the downloaded include directory.

Below is a simple step-by-step example using curl 7.76.1.

1) Check the Installed curl Version

First, confirm which curl version is available in your environment:

curl --version
Enter fullscreen mode Exit fullscreen mode

Example output:

curl 7.76.1 ...
Enter fullscreen mode Exit fullscreen mode

2) Confirm Which libcurl curl Is Actually Using

Before configuring the build, it is useful to confirm the exact libcurl.so path used by the curl binary. This helps you set CURL_LIBRARY correctly.

Run:

ldd $(which curl) | grep curl
        libcurl.so.4 => /lib64/libcurl.so.4 (0x00007faa934a6000)
Enter fullscreen mode Exit fullscreen mode

In this example, the relevant library path is:

  • /lib64/libcurl.so.4

3) Download the Matching curl Source Archive

Download the curl source tarball for version 7.76.1 from GitHub:

curl -LO https://github.com/curl/curl/archive/refs/tags/curl-7_76_1.tar.gz
Enter fullscreen mode Exit fullscreen mode

4) Extract the Archive

Unpack the downloaded file:

tar xvf curl-7_76_1.tar.gz
Enter fullscreen mode Exit fullscreen mode

This will create a directory such as curl-curl-7_76_1/ containing the source code and, importantly, the include/ directory.

5) Configure the Build with CMake

Now configure your build so that CMake uses:

  • The system-installed curl library (example: /lib64/libcurl.so.4)
  • The headers from the extracted curl source directory

Run:

cmake -B build -DCURL_LIBRARY=/lib64/libcurl.so.4 -DCURL_INCLUDE_DIR=./curl-curl-7_76_1/include
Enter fullscreen mode Exit fullscreen mode

Notes:

  • -B build tells CMake to generate build files into the build/ directory.
  • -DCURL_LIBRARY=... points to the libcurl shared library already present on the machine.
  • -DCURL_INCLUDE_DIR=./curl*/include uses a wildcard to match the extracted curl source folder and selects its include/ directory.

6) Build

Finally, compile using multiple jobs:

cmake --build build -j
Enter fullscreen mode Exit fullscreen mode

At this point, the build should be able to find curl headers from the extracted source package while linking against the system’s libcurl library, avoiding the need to install curl development packages in the environment.

Top comments (0)