build static curl executable from source

32 Views Asked by At
  • I'm trying to build a statically linked curl executable from source:
  • When I grep around1 the CMakeLists.txt, I find relevant flags:
$ git clone https://github.com/curl/curl.git
$ cd curl
$ grep -rn "STATIC\|SHARED" CMakeLists.txt | head -n 3
87:option(BUILD_SHARED_LIBS "Build shared libraries" ON)
88:option(BUILD_STATIC_LIBS "Build static libraries" OFF)
89:option(BUILD_STATIC_CURL "Build curl executable with static libcurl" OFF)

When I add them, I see the static build:

$ mkdir build
$ cd build
$ cmake -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_LIBS=ON -DBUILD_STATIC_CURL=ON ..
$ make
# ... omitted ...
[ 77%] Linking C static library libcurl.a
[ 77%] Built target libcurl_static
# ... omitted ...
[100%] Linking C executable curl
[100%] Built target curl

But I can't make the actual curl executable to be statically linked:

$ file ./src/curl
./src/curl: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=a43b285880dba6b1c2a1301fafb6240e232dbcad, for GNU/Linux 3.2.0, with debug_info, not stripped

1 is there any other way?

0

There are 0 best solutions below