Efinix-Inc / br2-efinix

Buildroot external tree for building Linux for Efinix RISC-V Sapphire SoC
MIT License
10 stars 4 forks source link

fatal error: opencv2/dnn.hpp: No such file or directory #14

Closed matteovit closed 4 months ago

matteovit commented 4 months ago

Building build-root for the Ti375 from the latest main branch:

source init.sh ti375c529 boards/efinix/ti375c529/hardware/soc/soc.h -p -e
make

I get the following error:

canny 1.0 Syncing from source dir /work/projects/efinix/br2-efinix/package/canny/src
rsync -au --chmod=u=rwX,go=rX  --exclude .svn --exclude .git --exclude .hg --exclude .bzr --exclude CVS /work/projects/efinix/br2-efinix/package/canny/src/ /work/projects/efinix/build_ti375c529/build/build/canny-1.0
canny 1.0 Configuring
canny 1.0 Building
/usr/bin/make  CXX=/work/projects/efinix/build_ti375c529/build/host/bin/riscv32-buildroot-linux-gnu-g++ PKG_CFG=/work/projects/efinix/build_ti375c529/build/host/bin/pkg-config -C /work/projects/efinix/build_ti375c529/build/build/canny-1.0
/work/projects/efinix/build_ti375c529/build/host/bin/riscv32-buildroot-linux-gnu-g++ -O2 `/work/projects/efinix/build_ti375c529/build/host/bin/pkg-config --cflags --libs opencv` canny.c -o canny
canny 1.0 Installing to target
mkdir -p /work/projects/efinix/build_ti375c529/build/target/usr/share/canny
/usr/bin/install -m 0755 -D /work/projects/efinix/build_ti375c529/build/build/canny-1.0/canny /work/projects/efinix/build_ti375c529/build/target/usr/bin/canny
/usr/bin/install -m 0664 -D /work/projects/efinix/build_ti375c529/build/build/canny-1.0/image.jpg /work/projects/efinix/build_ti375c529/build/target/usr/share/canny/image.jpg
cv2_detection 1.0 Syncing from source dir /work/projects/efinix/br2-efinix/package/cv2_detection/src
rsync -au --chmod=u=rwX,go=rX  --exclude .svn --exclude .git --exclude .hg --exclude .bzr --exclude CVS /work/projects/efinix/br2-efinix/package/cv2_detection/src/ /work/projects/efinix/build_ti375c529/build/build/cv2_detection-1.0
cv2_detection 1.0 Configuring
cv2_detection 1.0 Building
/usr/bin/make  CXX=/work/projects/efinix/build_ti375c529/build/host/bin/riscv32-buildroot-linux-gnu-g++ PKG_CFG=/work/projects/efinix/build_ti375c529/build/host/bin/pkg-config -C /work/projects/efinix/build_ti375c529/build/build/cv2_detection-1.0
/work/projects/efinix/build_ti375c529/build/host/bin/riscv32-buildroot-linux-gnu-g++ -O2 `/work/projects/efinix/build_ti375c529/build/host/bin/pkg-config --cflags --libs opencv` detection.cpp -o cv2_detection
detection.cpp:7:10: fatal error: opencv2/dnn.hpp: No such file or directory
 #include <opencv2/dnn.hpp>
          ^~~~~~~~~~~~~~~~~
efxmnalim commented 4 months ago

Please check the git log for buildroot repo then paste the output here. Try this

cd build_ti375c529/buildroot
git log --oneline -10
matteovit commented 4 months ago
matteo@zeus:/work/projects/efinix/build_ti375c529/buildroot$ git log --oneline -10
0d4c604da8 (HEAD, tag: 2021.05.3, origin/2021.05.x) Update for 2021.05.3
5a89e46bbd package/redis: security bump to v6.2.6
65391de0e8 package/gdb: append to dependencies in conditional
bc67998293 DEVELOPERS: adopt package/libite
f58c498450 package/uclibc: update to 1.0.39
718f59ff9e package/gst1-interpipe: bump version to 1.1.6
fb1dc8095f package/net-tools: add NET_TOOLS_CPE_ID_VENDOR
280ad9a585 package/libressl: bump to version 3.2.7
6ee815f77b package/libcurl: fix build with wolfssl
b420721f44 package/squid: security bump to version 4.17
efxmnalim commented 4 months ago

Seem like there are some patches are not applied to that repo. Try to apply the patches manually.

cd /work/projects/efinix/build_ti375c529/buildroot
git am /work/projects/efinix/br2-efinix/patches/buildroot/2021.05.3/*.patch

remove opencv build directory and rebuild again

cd /work/projects/efinix/build_ti375c529/build
rm -rf build/opencv3-3.4.13
make -j$(nproc)
matteovit commented 4 months ago

That didn't fix the problem. At the end the issue was a missing dependency in the cv2_detection package:

https://github.com/starwaredesign/br2-efinix/tree/fix-opencv-dnn-build-error

efxmnalim commented 4 months ago

The dependency already defines here https://github.com/Efinix-Inc/br2-efinix/blob/main/configs/efinix_ti375c529_defconfig#L133. The buildroot repo in build_ti375c529 directory is missing this patch https://github.com/Efinix-Inc/br2-efinix/blob/main/patches/buildroot/2021.05.3/0001-opencv3-enable-support-for-dnn-library.patch so that's why the compilation failed.

What is the output when you run the init.sh script?

matteovit commented 4 months ago

in this case it doesn't matter since OPENCV3_DNN is an option to the OpenCV package, but if it was a separate package, then adding it as dependency would be different than adding it to the defconfig.

if the patch wasn't applied correctly I would have expected to get an error related to BR2_PACKAGE_OPENCV3_DNN being defined in the defconfig but not in the package config.

Unfortunately I am not able to reproduce the issue again (it builds fine), even with a clean git clone in a different directory so I will close the ticket.

The only note for Ubuntu 22 is that the provided version of mtools generates an error and I had to compile a more recent version of mtool from the source code (this is the issue https://github.com/PartialVolume/shredos.x86_64/issues/120).