Can't compile dlib, it fails at 99% - opencv

I plan on beginning to work with facial recognition more, and so I tried to install dlib. I followed the instructions:
cd examples
mkdir build
cd build
cmake ..
cmake --build . --config Release
And the only one that failed was the last one. It ran fine up untill it got to 99% complete, and then:
Scanning dependencies of target train_shape_predictor_ex
[ 96%] Building CXX object CMakeFiles/train_shape_predictor_ex.dir/train_shape_predictor_ex.cpp.o
[ 96%] Linking CXX executable train_shape_predictor_ex
[ 96%] Built target train_shape_predictor_ex
Scanning dependencies of target using_custom_kernels_ex
[ 96%] Building CXX object CMakeFiles/using_custom_kernels_ex.dir/using_custom_kernels_ex.cpp.o
[ 97%] Linking CXX executable using_custom_kernels_ex
[ 97%] Built target using_custom_kernels_ex
Scanning dependencies of target video_tracking_ex
[ 97%] Building CXX object CMakeFiles/video_tracking_ex.dir/video_tracking_ex.cpp.o
[ 98%] Linking CXX executable video_tracking_ex
[ 98%] Built target video_tracking_ex
Scanning dependencies of target webcam_face_pose_ex
[ 98%] Building CXX object CMakeFiles/webcam_face_pose_ex.dir/webcam_face_pose_ex.cpp.o
[ 99%] Linking CXX executable webcam_face_pose_ex
/usr/local/lib/libopencv_highgui.so.2.4.11: undefined reference to `TIFFIsTiled#LIBTIFF_4.0'
/usr/local/lib/libopencv_highgui.so.2.4.11: undefined reference to `TIFFOpen#LIBTIFF_4.0'
/usr/local/lib/libopencv_highgui.so.2.4.11: undefined reference to `TIFFReadEncodedStrip#LIBTIFF_4.0'
/usr/local/lib/libopencv_highgui.so.2.4.11: undefined reference to `TIFFSetField#LIBTIFF_4.0'
/usr/local/lib/libopencv_highgui.so.2.4.11: undefined reference to `TIFFWriteScanline#LIBTIFF_4.0'
/usr/local/lib/libopencv_highgui.so.2.4.11: undefined reference to `TIFFGetField#LIBTIFF_4.0'
/usr/local/lib/libopencv_highgui.so.2.4.11: undefined reference to `TIFFScanlineSize#LIBTIFF_4.0'
/usr/local/lib/libopencv_highgui.so.2.4.11: undefined reference to `TIFFSetWarningHandler#LIBTIFF_4.0'
/usr/local/lib/libopencv_highgui.so.2.4.11: undefined reference to `TIFFSetErrorHandler#LIBTIFF_4.0'
/usr/local/lib/libopencv_highgui.so.2.4.11: undefined reference to `TIFFReadEncodedTile#LIBTIFF_4.0'
/usr/local/lib/libopencv_highgui.so.2.4.11: undefined reference to `TIFFReadRGBATile#LIBTIFF_4.0'
/usr/local/lib/libopencv_highgui.so.2.4.11: undefined reference to `TIFFClose#LIBTIFF_4.0'
/usr/local/lib/libopencv_highgui.so.2.4.11: undefined reference to `TIFFRGBAImageOK#LIBTIFF_4.0'
/usr/local/lib/libopencv_highgui.so.2.4.11: undefined reference to `TIFFReadRGBAStrip#LIBTIFF_4.0'
collect2: error: ld returned 1 exit status
make[2]: *** [webcam_face_pose_ex] Error 1
make[1]: *** [CMakeFiles/webcam_face_pose_ex.dir/all] Error 2
make: *** [all] Error 2
It looks to me like I'm just missing a few files. How would I fix that?

This is well-known problem of OpenCV with LibTIFF 4 on some Ubuntu versions. Take a look here:
http://answers.opencv.org/question/35642/libtiff_40-link-errors/

Related

Error building OpenCV in Ubuntu using cmake

Attempting to build open OpenCV in Ubuntu, following this tutorial (specifically the "Build core modules" section), and I get the following error:
[ 71%] Linking CXX executable ../../bin/opencv_test_highgui
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libfontconfig.so: undefined reference to 'uuid_parse#UUID_1.0'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libfontconfig.so: undefined reference to 'uuid_generate_random#UUID_1.0'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libfontconfig.so: undefined reference to 'uuid_unparse#UUID_1.0'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libfontconfig.so: undefined reference to 'uuid_copy#UUID_1.0'
collect2: error: ld returned 1 exit status
make[2]: *** [modules/highgui/CMakeFiles/opencv_test_highgui.dir/build.make:122: bin/opencv_test_highgui] Error 1
make1: *** [CMakeFiles/Makefile2:2754: modules/highgui/CMakeFiles/opencv_test_highgui.dir/all] Error 2
make: *** [Makefile:163: all] Error 2
I imagine this is a missing dependency, but I'm having a hard time finding it. Anyone have a fix?

Issues cross compile opencv 2.4.11 for ARM on x86_64 host

I've been trying to cross compile opencv for an ARM target system. My project is dependent to use opencv 2.4.11.
The target system is a petalinux 2017.2 running on a quad-core Cortex A53 of a Zynq Ultrascale+ FPGA.
My host system is an Ubuntu 16.04 x86_64.
I used the following toolchain.cmake file for configuration:
set( CMAKE_SYSTEM_NAME Linux)
set( CMAKE_SYSTEM_PROCESSOR arm)
set( CMAKE_C_COMPILER /home/benjaminh/petalinux_2017_2/tools/linux-i386/aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc)
set( CMAKE_CXX_COMPILER /home/benjaminh/petalinux_2017_2/tools/linux-i386/aarch64-linux-gnu/bin/aarch64-linux-gnu-g++)
set( CMAKE_FIND_ROOT_PATH /home/benjaminh/embedded_development/ultrazed_repo/scripts/rootfs_part)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
I performed the following steps:
wget https://github.com/Itseez/opencv/archive/2.4.11.zip
unzip 2.4.11.zip
cd opencv-2.4.11
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake ../
make -j4
As you can see, the build process failed with: error: unknown register name 'st' in 'asm'. It seems that it attemps to interpret a x86_64 library with an ARM compiler
[ 44%] Building CXX object modules/video/CMakeFiles/opencv_video.dir/src/bgfg_gaussmix.cpp.o
[ 44%] Building CXX object modules/photo/CMakeFiles/opencv_photo.dir/src/denoising.cpp.o
In file included from /home/benjaminh/petalinux_2017_2/tools/linux-i386/aarch64-linux-gnu/aarch64-linux-gnu/libc/usr/include/math.h:472:0,
from /home/benjaminh/petalinux_2017_2/tools/linux-i386/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/6.2.1/cmath:45,
from /home/benjaminh/petalinux_2017_2/tools/linux-i386/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/6.2.1/math.h:36,
from /home/benjaminh/embedded_development/opencv-2.4.11/modules/core/include/opencv2/core/types_c.h:94,
from /home/benjaminh/embedded_development/opencv-2.4.11/modules/core/include/opencv2/core/core.hpp:49,
from /home/benjaminh/embedded_development/opencv-2.4.11/modules/highgui/include/opencv2/highgui/highgui.hpp:46,
from /home/benjaminh/embedded_development/opencv-2.4.11/modules/highgui/src/precomp.hpp:47,
from /home/benjaminh/embedded_development/opencv-2.4.11/modules/highgui/src/cap_images.cpp:52:
/usr/include/x86_64-linux-gnu/bits/mathinline.h: In member function ‘virtual bool CvCapture_Images::setProperty(int, double)’:
/usr/include/x86_64-linux-gnu/bits/mathinline.h:889:3: error: unknown register name ‘st’ in ‘asm’
__lrint_code;
^
/usr/include/x86_64-linux-gnu/bits/mathinline.h:889:3: error: unknown register name ‘st’ in ‘asm’
__lrint_code;
^
modules/highgui/CMakeFiles/opencv_highgui.dir/build.make:86: recipe for target 'modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_images.cpp.o' failed
make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_images.cpp.o] Error 1
CMakeFiles/Makefile2:2275: recipe for target 'modules/highgui/CMakeFiles/opencv_highgui.dir/all' failed
make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 44%] Building CXX object modules/video/CMakeFiles/opencv_video.dir/src/lkpyramid.cpp.o
[ 44%] Building CXX object modules/video/CMakeFiles/opencv_video.dir/src/video_init.cpp.o
[ 44%] Building CXX object modules/video/CMakeFiles/opencv_video.dir/src/bgfg_gmg.cpp.o
[ 44%] Building CXX object modules/video/CMakeFiles/opencv_video.dir/src/tvl1flow.cpp.o
[ 44%] Building CXX object modules/video/CMakeFiles/opencv_video.dir/src/bgfg_gaussmix2.cpp.o
[ 44%] Linking CXX shared library ../../lib/libopencv_photo.so
[ 44%] Built target opencv_photo
[ 44%] Building CXX object modules/video/CMakeFiles/opencv_video.dir/src/kalman.cpp.o
[ 44%] Building CXX object modules/video/CMakeFiles/opencv_video.dir/src/simpleflow.cpp.o
[ 44%] Linking CXX shared library ../../lib/libopencv_video.so
[ 44%] Built target opencv_video
Makefile:160
: recipe for target 'all' failed
make: *** [all] Error 2
From time to time during the build process warnings like these occure, which indicates that there is something wrong with the set path:
cc1plus: warning: include location "/usr/include/glib-2.0" is unsafe for cross-compilation [-Wpoison-system-directories]
cc1plus: warning: include location "/usr/include/freetype2" is unsafe for cross-compilation [-Wpoison-system-directories]
cc1plus: warning: include location "/usr/include/x86_64-linux-gnu" is unsafe for cross-compilation [-Wpoison-system-directories]
For me it is not clear why it is taking the host path and not the given target root path.
Your toolchain file is incomplete. Does petalinux provide one?
You need to add directives so that make will not attempt to use host includes when building target objects:
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
You may also need to specify the target sys root:
set(CMAKE_SYSROOT /home/devel/petalinux-rootfs)

Building opencv 3.2.0 with contribution ERROR

I am trying to build opencv with opencv_contributions, but I can`t figure out this error at building.
I made cmake like this :
cmake -DOPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-master/modules/ ~/opencv-3.2.0/
And at the end of building i got this error:
[100%] Linking CXX executable ../../bin/opencv_perf_stitching
[100%] Built target opencv_perf_stitching
[100%] Linking CXX shared module ../../lib/cv2.so
/usr/bin/ld: CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o: relocation R_X86_64_PC32 against undefined symbol `_Z13pyopencv_fromIN2cv4MatxIdLi4ELi4EEEEP7_objectRKT_' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
modules/python2/CMakeFiles/opencv_python2.dir/build.make:393: recipe for target 'lib/cv2.so' failed
make[2]: *** [lib/cv2.so] Error 1
CMakeFiles/Makefile2:14221: recipe for target 'modules/python2/CMakeFiles/opencv_python2.dir/all' failed
make[1]: *** [modules/python2/CMakeFiles/opencv_python2.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2

OpenCV error while compiling ros workspace

recently, after installing OpenCV3, I am not able to use Baxter on Ubuntu 14.04 64 bit OS. However, I removed OpenCV3 later on but the catkin_make on ros indigo workspace is giving following error-
Linking CXX executable /home/ravi/ros_ws/devel/lib/baxter_sim_hardware/baxter_emulator
[100%] Built target baxter_sim_io
CMakeFiles/baxter_emulator.dir/src/baxter_emulator.cpp.o: In function `baxter_en::baxter_emulator::publish(std::string const&)':
baxter_emulator.cpp:(.text+0x2087): undefined reference to `cv::imread(cv::String const&, int)'
CMakeFiles/baxter_emulator.dir/src/baxter_emulator.cpp.o: In function `cv::String::~String()':
baxter_emulator.cpp:(.text._ZN2cv6StringD2Ev[_ZN2cv6StringD5Ev]+0x14): undefined reference to `cv::String::deallocate()'
CMakeFiles/baxter_emulator.dir/src/baxter_emulator.cpp.o: In function `cv::String::String(std::string const&)':
baxter_emulator.cpp:(.text._ZN2cv6StringC2ERKSs[_ZN2cv6StringC5ERKSs]+0x69): undefined reference to `cv::String::allocate(unsigned long)'
collect2: error: ld returned 1 exit status
make[2]: *** [/home/ravi/ros_ws/devel/lib/baxter_sim_hardware/baxter_emulator] Error 1
make[1]: *** [baxter_simulator/baxter_sim_hardware/CMakeFiles/baxter_emulator.dir/all] Error 2
make: *** [all] Error 2
Invoking "make -j8 -l8" failed
OpenCV3 was installed from the source using this script. This script has installed some additional libraries as well. I removed OpenCV3 by following command-
cd OpenCV/build
sudo make unistall
sudo ldconfig
but catkin_make is still showing same error.

OpenCV with ffmpeg on Fedora 22

I am trying to compile OpenCV 3.0 on Fedora 22 with ffmpeg. I encounter the following error:
[ 26%] Building CXX object
modules/core/CMakeFiles/opencv_perf_core.dir/perf/perf_bitwise.cpp.o
Linking CXX executable /global/OpenCV/opencv_perf_core
../../lib/libopencv_videoio.so.3.0.0: undefined reference to `swr_free'
../../lib/libopencv_videoio.so.3.0.0: undefined reference to `swr_init'
../../lib/libopencv_videoio.so.3.0.0: undefined reference to `swr_is_initialized'
../../lib/libopencv_videoio.so.3.0.0: undefined reference to `lzma_code'
../../lib/libopencv_videoio.so.3.0.0: undefined reference to `lzma_end'
../../lib/libopencv_videoio.so.3.0.0: undefined reference to `swr_close'
../../lib/libopencv_videoio.so.3.0.0: undefined reference to `swr_convert'
../../lib/libopencv_videoio.so.3.0.0: undefined reference to `swr_alloc'
../../lib/libopencv_videoio.so.3.0.0: undefined reference to `lzma_stream_decoder'
collect2: error: ld returned 1 exit status
modules/core/CMakeFiles/opencv_perf_core.dir/build.make:770: recipe for target '/global/OpenCV/opencv_perf_core' failed
make[2]: *** [/global/OpenCV/opencv_perf_core] Error 1
CMakeFiles/Makefile2:1245: recipe for target 'modules/core/CMakeFiles/opencv_perf_core.dir/all' failed
make[1]: *** [modules/core/CMakeFiles/opencv_perf_core.dir/all] Error 2
Makefile:136: recipe for target 'all' failed
make: *** [all] Error 2
Any help would be highly appreciated !

Resources