Error in building with ninja

$ ninja
[1/301] Linking CXX static library src/libswipl.a
[2/301] Generating qrc_swipl-win.cpp
[3/301] Linking CXX executable src/swipl
FAILED: src/swipl
: && /usr/bin/c++ -O3 -DNDEBUG src/CMakeFiles/swipl.dir/pl-main.c.o -o src/swipl -Wl,-rpath,:::::::::::::::::::::::::::::::::::::::::::: /usr/lib/x86_64-linux-gnu/ src/libswipl.a -lcurses /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ packages/clib/memfile.a -pthread packages/clib/files.a packages/clib/uri.a packages/clib/readutil.a packages/clib/prolog_stream.a packages/clib/md54pl.a packages/clib/crypt.a packages/clib/hashstream.a packages/clib/sha4pl.a packages/clib/cgi.a packages/clib/time.a packages/clib/process.a packages/clib/streaminfo.a packages/clib/mallocinfo.a packages/clib/unix.a packages/clib/uid.a packages/clib/rlimit.a packages/clib/syslog.a packages/clib/sched.a packages/clib/uuid.a packages/clib/socket.a /usr/lib/x86_64-linux-gnu/ -lm -lrt -lcrypt /usr/lib/x86_64-linux-gnu/ -lnsl /usr/lib/x86_64-linux-gnu/ -lm -lrt -lcrypt /usr/lib/x86_64-linux-gnu/ -lnsl packages/inclpr/inclpr.a packages/cpp/test_ffi.a packages/cpp/test_cpp.a packages/http/json.a packages/http/http_stream.a packages/http/websocket.a packages/ltx2htm/tex.a packages/nlp/double_metaphone.a packages/nlp/porter_stem.a packages/nlp/isub.a packages/nlp/snowball.a packages/nlp/libstemmer_c/liblibstemmer.a packages/redis/redis4pl.a packages/PDT/pdt_console.a packages/protobufs/protobufs.a packages/semweb/turtle.a packages/semweb/ntriples.a packages/semweb/rdf_db.a packages/sgml/sgml2pl.a packages/table/table.a packages/utf8proc/unicode4pl.a packages/zlib/zlib4pl.a packages/archive/archive4pl.a /usr/lib/x86_64-linux-gnu/ packages/odbc/odbc4pl.a /usr/lib/x86_64-linux-gnu/ packages/bdb/bdb4pl.a /usr/lib/x86_64-linux-gnu/ packages/pcre/pcre4pl.a /usr/lib/x86_64-linux-gnu/ packages/yaml/yaml4pl.a /usr/lib/x86_64-linux-gnu/ packages/ssl/ssl4pl.a /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ packages/ssl/crypto4pl.a packages/tipc/tipc.a packages/xpce/pl2xpce.a /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ packages/libedit/libedit4pl.a /usr/lib/x86_64-linux-gnu/ packages/readline/readline4pl.a /usr/lib/x86_64-linux-gnu/ && :
/usr/bin/ld: src/libswipl.a(pl-cstack.c.o): undefined reference to symbol ‘dladdr@@GLIBC_2.2.5
/usr/bin/ld: /lib/x86_64-linux-gnu/ error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
[4/301] Building CXX object packages/swipl-win/CMakeFiles/swipl-win.dir/main.cpp.o
[5/301] Building CXX object packages/swipl-win/CMakeFiles/swipl-win.dir/Swipl_IO.cpp.o
[6/301] Building CXX object packages/swipl-win/CMakeFiles/swipl-win.dir/pqMainWindow.cpp.o
[7/301] Building CXX object packages/swipl-win/CMakeFiles/swipl-win.dir/Preferences.cpp.o
[8/301] Building CXX object packages/swipl-win/CMakeFiles/swipl-win.dir/swipl-win_autogen/mocs_compilation.cpp.o
[9/301] Building CXX object packages/swipl-win/CMakeFiles/swipl-win.dir/SwiPrologEngine.cpp.o
ninja: build stopped: subcommand failed.

$ uname -a
Linux debian 5.10.0-27-amd64 #1 SMP Debian 5.10.205-2 (2023-12-31) x86_64 GNU/Linux

cat /etc/debian_version

Have you completed the installation of the dependencies (listed on this page) ?
In particular, the section about Qt5:

sudo apt-get install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools

Anyway, I think you can drop the swipl-win package build step giving to CMake the option


(I would clean the build directory before to run CMake again with the additional argument,)

This looks a bit strange. What CMake options did you pass? Looks like you try to build a statically linked system? I’m also a bit curious where the C++ compiler/linker comes from. The core is all plain C.

You are right that problem is in building a statically linked system! I thought this myself, but my another error was that I have tried clean with “ninja clean”, but it is required to erase everything in “build” folder!

After erasing “build” folder and: “cmake -DCMAKE_INSTALL_PREFIX=/opt/prolog/swipl -DCMAKE_BUILD_TYPE=Release -DVMI_FUNCTIONS=ON -DSWIPL_INSTALL_IN_LIB=ON -DSWIPL_INSTALL_IN_SHARE=ON -DINSTALL_TESTS=ON -G Ninja …” , ninja build finished without errors. Cmake options I have had before, and they caused problem, are “-DSWIPL_STATIC_LIB=ON -DSTATIC_EXTENSIONS=ON”.

Although now ctest shows:

99% tests passed, 1 tests failed out of 81

Total Test time (real) = 25.98 sec

The following tests FAILED:
79 - jpl:java_in_prolog (SEGFAULT)
Errors while running CTest"

after “ninja install”:

@debian:/opt/prolog/swipl$ find . -iname *jpl*

I assume build and installation is now in order.

Thank you for response. Problem was because I putted cmake options for building a statically linked system, and I didn’t erase “build” folder after repeating cmake with different options.

1 Like

Indeed. Typically I use multiple build directories for multiple configurations. As the build does not write anything in the source tree, this works just fine. .gitignore ignores all build.* directories, so I name them e.g. build.static-extensions, etc.

Building using -DSTATIC_EXTENSIONS=ON seems to work fine, except that you need to disable the Janus Python interface (pushed a patch to do this automatically). Surely, not all combinations of CMake options work.

No clue why JPL crashes. Should work fine on Debian Bullseye using OpenJDK. Do you use another Java version?

@debian:/opt/prolog/swipl$ java -version
openjdk version “17.0.9” 2023-10-17
OpenJDK Runtime Environment (build 17.0.9+9-Debian-1deb11u1)
OpenJDK 64-Bit Server VM (build 17.0.9+9-Debian-1deb11u1, mixed mode, sharing)

But JPL is not my primary concern at moment. Will be in a future, but I will look into it when comes in focus.