openzim / zim-tools

Various ZIM command line tools
https://download.openzim.org/release/zim-tools/
GNU General Public License v3.0
123 stars 34 forks source link

make sure that static linkage works for zim-tools #343

Closed neeraj9 closed 1 year ago

neeraj9 commented 1 year ago

I have tested the changes on Raspberry Pi 4, Model B.

The earlier version did not work as-is because of the failure with libbz2, which this change attempts to fix. The build fails as follows with the following error without this change.

c++  -o src/zimwriterfs/zimwriterfs 'src/zimwriterfs/99e202e@@zimwriterfs@exe/zimwriterfs.cpp.o' 'src/zimwriterfs/99e202e@@zimwriterfs@exe/tools.cpp.o' 'src/zimwriterfs/99e202e@@zimwriterfs@exe/.._tools.cpp.o' 'src/zimwriterfs/99e202e@@zimwriterfs@exe/zimcreatorfs.cpp.o' -Wl,--as-needed -Wl,--no-undefined -static-libstdc++ --static -Wl,--whole-archive -Wl,--start-group -lpthread -Wl,--no-whole-archive -pthread /usr/local/lib/aarch64-linux-gnu/libzim.a /usr/lib/aarch64-linux-gnu/liblzma.a /usr/lib/aarch64-linux-gnu/libzstd.a /usr/local/lib/libxapian.a /usr/lib/aarch64-linux-gnu/libuuid.a /usr/lib/aarch64-linux-gnu/libz.a -lrt /usr/lib/aarch64-linux-gnu/libicui18n.a /usr/lib/aarch64-linux-gnu/libicuuc.a /usr/lib/aarch64-linux-gnu/libicudata.a -ldl -lm /usr/lib/aarch64-linux-gnu/libgumbo.a -lmagic -Wl,--end-group
/usr/bin/ld: /usr/lib/aarch64-linux-gnu/libicuuc.a(putil.ao): in function `uprv_dl_open_66':
(.text+0x16c0): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/local/lib/libxapian.a(tcpclient.o): in function `Resolver::Resolver(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, int)':
tcpclient.cc:(.text._ZN8ResolverC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEii[_ZN8ResolverC5ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEii]+0x140): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libmagic.a(compress.o): in function `uncompressbuf':
(.text+0x658): undefined reference to `BZ2_bzDecompressInit'
/usr/bin/ld: (.text+0x6a0): undefined reference to `BZ2_bzDecompress'
/usr/bin/ld: (.text+0x6c0): undefined reference to `BZ2_bzDecompressEnd'
collect2: error: ld returned 1 exit status
[41/51] Compiling C++ object 'test/9f86d08@@zimwriterfs-zimcreatorfs@exe/gtest-all.cc.o'.
ninja: build stopped: subcommand failed.
kelson42 commented 1 year ago

Libzim shoukd be linked to libbz2, not the the zim-tools... and for sure not zimwriterfs.

@neeraj9 Please open a ticket describing exactly what does not work.

mgautierfr commented 1 year ago

/usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libmagic.a(compress.o): in function `uncompressbuf

This is libmagic which use bz2. We don't.

We use a somehow old way to detect magic library and it as been probably made this way as libmagic didn't provide a libmagic.pc at the time. Now it is the case so we would better fix the dependency to libmagic.

neeraj9 commented 1 year ago

sounds good.