# Are Linux static builds no longer supported by 9.3.25?

**URL:** <https://swi-prolog.discourse.group/t/are-linux-static-builds-no-longer-supported-by-9-3-25/9100>\
**Category:** Installing\
**Created:** [July 15, 2025, 6:39pm UTC](https://swi-prolog.discourse.group/t/are-linux-static-builds-no-longer-supported-by-9-3-25/9100 "2025-07-15T18:39:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![alanbur](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/alanbur/32/7166_2.png) [@alanbur](https://swi-prolog.discourse.group/u/alanbur)\
**Post date:** [July 15, 2025, 6:39pm UTC](https://swi-prolog.discourse.group/t/are-linux-static-builds-no-longer-supported-by-9-3-25/9100/1 "2025-07-15T18:39:54Z")

</div>

If I try to build with `-DSWIPL_STATIC_LIB=ON -DSTATIC_EXTENSIONS=ON` the first problem is that `-DCMAKE_BUILD_TYPE=PGO` doesn’t work, but even if I switch to `-DCMAKE_BUILD_TYPE=Release` the build blows up:

```prolog
[382/2559] Building C object src/CMakeFiles/swiplobjs.dir/os/pl-cstack.c.o
FAILED: src/CMakeFiles/swiplobjs.dir/os/pl-cstack.c.o 
/opt/rh/devtoolset-12/root/usr/bin/cc -Isrc -I../src -O2 -fvisibility=hidden -Wall -fno-strict-aliasing -std=gnu11 -MD -MT src/CMakeFiles/swiplobjs.dir/os/pl-cstack.c.o -MF src/CMakeFiles/swiplobjs.dir/os/pl-cstack.c.o.d -o src/CMakeFiles/swiplobjs.dir/os/pl-cstack.c.o -c ../src/os/pl-cstack.c
../src/os/pl-cstack.c: In function ‘print_trace’:
../src/os/pl-cstack.c:425:15: warning: unused variable ‘info’ [-Wunused-variable]
  425 | { Dl_info info;
      | ^~~~../src/os/pl-cstack.c: At top level:
../src/os/pl-cstack.c:456:5: error: expected identifier or ‘(’ before ‘else’
  456 | } else
      | ^~~~../src/os/pl-cstack.c:459:1: error: expected identifier or ‘(’ before ‘}’ token
  459 | }
      | ^
../src/os/pl-cstack.c:356:1: warning: ‘addr2line’ defined but not used [-Wunused-function]
  356 | addr2line(const char *fname, uintptr_t offset, char *buf, size_t size)
      | ^ ~~~~~~~~
[404/2559] Building C object src/CMakeFiles/swiplobjs.dir/pl-index.c.o
In file included from ../src/pl-incl.h:2968,
                 from ../src/pl-index.h:37,
                 from ../src/pl-index.c:37:
../src/pl-data.h: In function ‘update_primary_index___LD’:
../src/pl-data.h:213:30: warning: ‘key’ may be used uninitialized [-Wmaybe-uninitialized]
  213 | #define tagex(w) ((w) & (TAG_MASK|STG_MASK))
      | ^
../src/pl-index.c:3629:10: note: ‘key’ was declared here
 3629 | word key;
      | ^~~
[415/2559] Building C object src/CMakeFiles/swiplobjs.dir/pl-wam.c.o
ninja: build stopped: subcommand failed.

```

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [July 16, 2025, 7:21am UTC](https://swi-prolog.discourse.group/t/are-linux-static-builds-no-longer-supported-by-9-3-25/9100/2 "2025-07-16T07:21:15Z")

</div>

It depends on the platform, I guess. It surely works in general as the WASM version is built this way (and this is the primary motivation). On Linux, this works for me:

```prolog
cmake -DSTATIC_EXTENSIONS=ON \
      -DINSTALL_DOCUMENTATION=OFF \
      -DSWIPL_PACKAGE_LIST="clib;plunit" -G Ninja ..

```

It has some trouble compiling the library as .qlf. That probably needs some tweaking with the set of included packages and/or some additional conditional compilation to avoid including stuff that does not exist.

This does not use `-DSWIPL_STATIC_LIB=ON`, but that seems implied. `swipl` does not link to `libswipl.so` and instead, there is a `libswipl.a` as part of the build.

I don’t know your platform. I guess you need to find the right conditions to disable that route for printing crash information (that is what `pl-cstack.c` does). That code is a bit confusing at it is highly platform dependent and (thus) it is more “cpp” code than C ☹

---

<div class="post-metadata">

**Author:** ![alanbur](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/alanbur/32/7166_2.png) [@alanbur](https://swi-prolog.discourse.group/u/alanbur)\
**Post date:** [July 16, 2025, 8:35am UTC](https://swi-prolog.discourse.group/t/are-linux-static-builds-no-longer-supported-by-9-3-25/9100/3 "2025-07-16T08:35:32Z")

</div>

Thanks, the platform is a RedHat derivative, but an old one as I want binary compatibility with it - I’ve already had to build a couple of dependencies (eg PCRE) from source. If I build swipl as shared I have to include a lot of shared libraries in the bundle if I want to run it on newer OS versions, so I was investigating if static linking would be a better option.

I think the trick will be finding the right set of things to put in `-DSWIPL_PACKAGE_LIST`, as you say. Or just don’t support such an ancient Linux version 😆

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [July 16, 2025, 8:53am UTC](https://swi-prolog.discourse.group/t/are-linux-static-builds-no-longer-supported-by-9-3-25/9100/4 "2025-07-16T08:53:02Z")

</div>

Maybe the flatpak or docker version is an option?

You build problem won’t go away with the package selection as it breaks on `pl-cstack.c`, which is part of the core. That is probably fixable, but possibly hard. Anyway, unless you also link to the static system libraries, avoiding SWI-Prolog specific shared objects won’t help fixing compatibility issues.

---

<div class="post-metadata">

**Author:** ![alanbur](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/alanbur/32/7166_2.png) [@alanbur](https://swi-prolog.discourse.group/u/alanbur)\
**Post date:** [July 16, 2025, 9:56am UTC](https://swi-prolog.discourse.group/t/are-linux-static-builds-no-longer-supported-by-9-3-25/9100/5 "2025-07-16T09:56:40Z")

</div>

All good points, thanks. As to the libraries, some of the shared ones I copied were older versions of system libraries - I basically ran `pldd` on the running app and pruned that list a bit. But for a static builds the `pl-cstack.c` issue seems like the killer, as you say - I didn’t realise it was part of the core.

I think your docker suggestion is the best option, thanks.

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [July 16, 2025, 10:12am UTC](https://swi-prolog.discourse.group/t/are-linux-static-builds-no-longer-supported-by-9-3-25/9100/6 "2025-07-16T10:12:38Z")

</div>

I forgot how it is called, but there used to be a Linux packager that allows you to compile your application on a modern system and then run it. It inspects what the application is using and packages every file nicely into a self-contained directory.
