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/libtcmalloc_minimal.so src/libswipl.a -lcurses /usr/lib/x86_64-linux-gnu/libform.so /usr/lib/x86_64-linux-gnu/libgmp.so 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/libz.so -lm -lrt -lcrypt /usr/lib/x86_64-linux-gnu/libossp-uuid.so -lnsl /usr/lib/x86_64-linux-gnu/libz.so -lm -lrt -lcrypt /usr/lib/x86_64-linux-gnu/libossp-uuid.so -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/libarchive.so packages/odbc/odbc4pl.a /usr/lib/x86_64-linux-gnu/libodbc.so packages/bdb/bdb4pl.a /usr/lib/x86_64-linux-gnu/libdb.so packages/pcre/pcre4pl.a /usr/lib/x86_64-linux-gnu/libpcre2-8.so packages/yaml/yaml4pl.a /usr/lib/x86_64-linux-gnu/libyaml.so packages/ssl/ssl4pl.a /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib/x86_64-linux-gnu/libcrypto.so packages/ssl/crypto4pl.a packages/tipc/tipc.a packages/xpce/pl2xpce.a /usr/lib/x86_64-linux-gnu/libXinerama.so /usr/lib/x86_64-linux-gnu/libXpm.so /usr/lib/x86_64-linux-gnu/libXext.so /usr/lib/x86_64-linux-gnu/libXt.so /usr/lib/x86_64-linux-gnu/libX11.so /usr/lib/x86_64-linux-gnu/libSM.so /usr/lib/x86_64-linux-gnu/libICE.so /usr/lib/x86_64-linux-gnu/libXft.so /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib/x86_64-linux-gnu/libfontconfig.so /usr/lib/x86_64-linux-gnu/libjpeg.so packages/libedit/libedit4pl.a /usr/lib/x86_64-linux-gnu/libedit.so packages/readline/readline4pl.a /usr/lib/x86_64-linux-gnu/libreadline.so && :
/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/libdl.so.2: 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
11.8

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

-DSWIPL_PACKAGES_QT=OFF

(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*
./lib/swipl/lib/x86_64-linux/libjpl.so
./lib/swipl/lib/jpl.jar
./lib/swipl/test/packages/jpl
./lib/swipl/test/packages/jpl/test_jpl.pl
./lib/swipl/test/packages/jpl/src/test/java/jpltest.jar
./lib/swipl/library/jpl.pl
./share/swipl/doc/packages/examples/jpl
./share/swipl/doc/packages/examples/jpl/prolog/jpl_table_demo.pl
./share/swipl/doc/packages/examples/jpl/prolog/jpl_text_entry_demo.pl
./share/swipl/doc/packages/examples/jpl/prolog/jpl_jlist_demo.pl
./share/swipl/doc/packages/examples/jpl/prolog/jpl_versions_demo.pl
./share/swipl/doc/packages/examples/jpl/prolog/jpl_colour_choose_demo.pl
./share/swipl/doc/packages/jpl.html”

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.