scantailor-libs-build icon indicating copy to clipboard operation
scantailor-libs-build copied to clipboard

CMake error despite all dependencies being installed

Open Fifis opened this issue 4 years ago • 3 comments

There is an issue in Ubuntu 18.04 and systems based on it (including the very popular Linux Mint 19.3): after installing the all the dependencies and compilers and doing cmake -G "Unix Makefiles" --build .., the compiler throws a bunch of errors like

-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found JPEG: /usr/lib/x86_64-linux-gnu/libjpeg.so
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11"
-- Found PNG: /usr/lib/x86_64-linux-gnu/libpng.so (found version "1.6.34")
-- Found TIFF: /usr/lib/x86_64-Linux-gnu/Libtiff.so (found version "4.0.9")
-- Boost version: 1.65.1
-- Found the following Boost libraries:
--   unit_test_framework
--   prg_exec_monitor
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread create
-- Looking for pthread create - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Configuring done

CMake Error at src/core/CMakeLists.txt:120 (add library):
  Target "core" links to target "JPEG::JPEG" but the target was not found.
  Perhaps a find package() call is missing for an IMPORTED target, or an
  ALIAS target is missing?

CMake Error at src/core/interaction/CMakeLists.txt:14 (add_library):
  Target "interaction" links to target "JPEG::JPEG" but the target was not
  found. Perhaps a find package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?

The version of CMake that is proposed in the repositories for Ubuntu-18.04-based distributions is 3.10, and it is probably slightly broken, so what helped—and what is currently outside the scope of this tutorial and what a strongly recommend to the ‘Troubleshooting’ section is the following: — If CMake produces errors complaining about not finding targets despite all libraries with development headers already being present in the system, then remove CMake (sudo apt remove cmake cmake-data) and compile CMake from sources:

cd cmake-3.17.1/
./bootstrap --parallel=2 -- -DCMAKE_BUILD_TYPE:STRING=Release
make -j2
make install

(or replacing the last line with sudo checkinstall --fstrans=no for easier uninstallation even when the sources are gone), and after that, CMake should find all libraries and compile scantailor-advanced without a hindrance.

Fifis avatar Apr 18 '20 06:04 Fifis

or replacing the last line with sudo checkinstall --fstrans=no for easier uninstallation even when the sources are gone

Have you tried cpack -G "DEB" and installing the resulting package with the default package manager? There is also an alternative approach without building: just to download cmake binaries, unpack, output all the files in the cmake directory via find into a text file, install with cp, and then use xargs with rm for removing. The only downside you need to keep that text file somewhere.

4lex4 avatar Apr 21 '20 05:04 4lex4

Yeah, both cpack -G "DEB" (for cmake version 3.17.1) and sudo checkinstall --fstrans=no work without a hindrance after a successful compilation, so it is not the point of this issue. It is cmake that was throwing errors (the 3.10 cmake supplied in Linux Mint 19.3) before the compilation, after which make would return a compilation error.

Fifis avatar Apr 24 '20 11:04 Fifis

So if I understand things correctly, scantailor-advanced can't be built with CMake 3.10 (the default in Ubuntu 18.04)?

bertvandepoel avatar Jul 14 '22 11:07 bertvandepoel