luxonis / depthai-core

DepthAI C++ Library
MIT License
238 stars 127 forks source link

Cross Compilation #834

Open rengglian opened 1 year ago

rengglian commented 1 year ago

For various projects I'm using a Docker Image to write application for Raspberry Pies. Some third party libraries which are used and build within the container: libusb, opencv, aravis project, boost, apache thrift.

Now I'm trying to add an OAK-D-Lite to a project, but I cannot compile depthai-core:

-- Checking support for ARCHIVE_CRYPTO_SHA1_LIBSYSTEM -- not found
-- Checking support for ARCHIVE_CRYPTO_SHA256_LIBSYSTEM
-- Checking support for ARCHIVE_CRYPTO_SHA256_LIBSYSTEM -- not found
-- Checking support for ARCHIVE_CRYPTO_SHA384_LIBSYSTEM
-- Checking support for ARCHIVE_CRYPTO_SHA384_LIBSYSTEM -- not found
-- Checking support for ARCHIVE_CRYPTO_SHA512_LIBSYSTEM
-- Checking support for ARCHIVE_CRYPTO_SHA512_LIBSYSTEM -- not found
-- Checking support for ARCHIVE_CRYPTO_MD5_LIBMD
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
LIBMD_LIBRARY
    linked by target "cmTC_1da53" in directory /root/.hunter/_Base/cb0ea1f/a273c36/079a0bf/Build/libarchive-luxonis/Build/libarchive-luxonis-Release-prefix/src/libarchive-luxonis-Release-build/CMakeFiles/CMakeTmp

CMake Error at CMakeLists.txt:875 (TRY_COMPILE):
  Failed to generate test project build system.
Call Stack (most recent call first):
  CMakeLists.txt:2007 (CHECK_CRYPTO)

It seems the problem is with libarchive.

Here are the commands I tried:

git clone --depth 1 -b v2.21.2 https://github.com/luxonis/depthai-core.git /home/dev/downloads/depthai-core
git submodule update --init --recursive
cmake -S. -Bbuild -DCMAKE_TOOLCHAIN_FILE=/home/dev/toolchain_settings/docker_toolchain.cmake -D'BUILD_SHARED_LIBS=ON' -DDEPTHAI_ENABLE_BACKWARD=OFF

No issue with OpenCV:

git clone --depth 1 -b 4.7.0 https://github.com/opencv/opencv.git /home/dev/downloads/opencv
mkdir build
cd build
cmake \
   -DBUILD_opencv_gapi=OFF \
   -DWITH_LAPACK=OFF \
   -DWITH_ITT=OFF \
   -DWITH_GTK=OFF \
   -DWITH_GSTREAMER=OFF \
   -DWITH_JASPER=OFF \
   -DWITH_IPP=OFF \
   -DWITH_V4L=OFF \
   -DWITH_WEBP=OFF \
   -DWITH_VTK=OFF \
   -DWITH_PROTOBUF=OFF \
   -DWITH_CUDA=OFF \
   -DWITH_1394=OFF \
   -DENABLE_PRECOMPILED_HEADER=NO \
   -DBUILD_TESTS=OFF \
   -DBUILD_PERF_TESTS=NO \
   -DCMAKE_TOOLCHAIN_FILE=/home/dev/toolchain_settings/docker_toolchain.cmake \
   -DCMAKE_INSTALL_PREFIX=/usr/local \
   ..

I would prefer to build the everything in a docker container (devops/workstation), than on a actual raspberry pi 4.

Did someone manage to cross compile it successfully? Any hints?

themarpe commented 1 year ago

@rengglian Do you mind testing some later version of libarchive's cmake fork? Or perhas merging with luxonis/libarchive with latest master libarchive/libarchive?

By quick look, it probably boils down to not having openssl - then libmd library is tried, but isn't correctly guarded if that doesn't exist.

IMO, try apt install libssl-dev in container before installing depthai-core