opencv c++ fails the make -j4 - c++

I'm trying to install OpenCV in c++ locally on my machine with Ubuntu 20.04.5 LST following this manual.
The first two steps went good, but I'm stuck on the make -j4 substep of the third step. Running this command results in the following error message:
[ 83%] Linking CXX executable ../../bin/opencv_test_highgui
[ 83%] Built target opencv_test_calib3d
[ 83%] Built target opencv_perf_objdetect
[ 83%] Built target opencv_test_objdetect
[ 83%] Built target opencv_perf_stitching
[ 83%] Built target opencv_test_stitching
[ 83%] Built target opencv_perf_video
Scanning dependencies of target opencv_gapi
Scanning dependencies of target opencv_interactive-calibration
[ 83%] Built target opencv_test_video
[ 83%] Building CXX object apps/interactive-calibration/CMakeFiles/opencv_interactive-calibration.dir/calibController.cpp.o
[ 83%] Building CXX object apps/interactive-calibration/CMakeFiles/opencv_interactive-calibration.dir/calibPipeline.cpp.o
/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
make[1]: *** [CMakeFiles/Makefile2:2958: modules/highgui/CMakeFiles/opencv_test_highgui.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 83%] Building CXX object apps/interactive-calibration/CMakeFiles/opencv_interactive-calibration.dir/frameProcessor.cpp.o
[ 83%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/api/grunarg.cpp.o
[ 83%] Building CXX object apps/interactive-calibration/CMakeFiles/opencv_interactive-calibration.dir/main.cpp.o
[ 83%] Building CXX object apps/interactive-calibration/CMakeFiles/opencv_interactive-calibration.dir/parametersController.cpp.o
[ 83%] Building CXX object apps/interactive-calibration/CMakeFiles/opencv_interactive-calibration.dir/rotationConverters.cpp.o
[ 83%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/api/gorigin.cpp.o
[ 83%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/api/gmat.cpp.o
[ 83%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/api/garray.cpp.o
[ 83%] Linking CXX executable ../../bin/opencv_interactive-calibration
I found this answer to get the missing libraries, but as I see its for the red hat, and I need it for Ubuntu.
Thanks in advance for any help.

I suppose you are in need of the uuid-dev package. Try running:
sudo apt install uuid-dev

Related

Cannot find lpublic library

Trying to compile my project on Centos 8.2 using cmake 3.12, im facing with the following error:
cannot find -lpublic
here is full log:
[ 20%] Building CXX object CMakeFiles/ .cpp.o
[ 40%] Building CXX object CMakeFiles/ .cpp.o
[ 60%] Linking CXX shared library .so
[ 60%] Built target myproj
Scanning dependencies of target nist01
[ 80%] Building CXX object CMakeFiles/ .cpp.o
[100%] Linking CXX executable
/usr/bin/ld: cannot find -lpublic
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/nist01.dir/build.make:85: ...] Error 1
make[1]: *** [CMakeFiles/Makefile2:105: CMakeFiles/...] Error 2
make: *** [Makefile:84: all] Error 2
Tried to find something on the internet, but nothing shown up.
Thanks for your help.
That seems like you try to link against the target "public", which is a suspicious target name. It might be target_link_libraries command with lowercase public instead of uppercase one, like target_link_libraryies(nist01 public something) instead of target_link_libraries(nist01 PUBLIC something).

Compiling OpenCV errors

I trying to install opencv on my raspberry pi 3b+. Iam basing on tutorial from pyimagesearch.Iam on Step #5: Compile and Install OpenCV. I got errors after I execute make command. On 15% I got errors like on the screen.
Errors:
[ 22%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/fully_connected_layer.cpp.o
/home/pi/opencv-3.1.0/modules/videoio/src/cap_ffmpeg_impl.hpp: In member function ‘bool OutputMediaStream_FFMPEG::open(const char*, int, int, double)’:
/home/pi/opencv-3.1.0/modules/videoio/src/cap_ffmpeg_impl.hpp:2207:30: warning: ignoring return value of ‘int avformat_write_header(AVFormatContext*, AVDictionary**)’, declared with attribute warn_unused_result [-Wunused-result]
avformat_write_header(oc_, NULL);
~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
make[2]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/build.make:154: modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_ffmpeg.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:4209: modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 22%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/im2col.cpp.o
[ 22%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/layers_common.cpp.o
[ 22%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/lrn_layer.cpp.o
[ 22%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/mvn_layer.cpp.o
[ 22%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/pooling_layer.cpp.o
[ 22%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/reshape_layer.cpp.o
[ 22%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/slice_layer.cpp.o
[ 22%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/softmax_layer.cpp.o
[ 23%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/split_layer.cpp.o
[ 23%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/torch/THDiskFile.cpp.o
[ 23%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/torch/THFile.cpp.o
[ 23%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/torch/THGeneral.cpp.o
[ 23%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/torch/torch_importer.cpp.o
[ 23%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/opencl_kernels_dnn.cpp.o
[ 23%] Linking CXX shared library ../../lib/libopencv_dnn.so
[ 23%] Built target opencv_dnn
make: *** [Makefile:163: all] Error 2
When my cmake looks like:
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.1.0/modules \
-D ENABLE_PRECOMPILED_HEADERS=OFF \
-D WITH_TBB=OFF \
-D BUILD_EXAMPLES=ON ..
I got errors like:
make[2]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/build.make:154: modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_ffmpeg.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:4209: modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
make: *** [Makefile:163: all] Error 2
I will be greateful for any advice.
Okey, I handled the problem. My solution was to install brand new Raspberry Pi Buster image on sd card. Then I installed opencv basing on another tutorial from pyimagesearch.

Build docker image works local but doesn't work on docker hub - cmake

I have created a simple Dockerfile and posted this on github.
https://github.com/Josvds/dotnetopencv
When running this on my local machine (after docker system prune) works fine
[ 76%] Building CXX object modules/cvv/CMakeFiles/opencv_cvv.dir/src/qtutil/matchview/keypointvaluechooser.cpp.o
[ 76%] Building CXX object modules/cvv/CMakeFiles/opencv_cvv.dir/src/qtutil/matchview/matchintervallselection.cpp.o
[ 76%] Building CXX object modules/cvv/CMakeFiles/opencv_cvv.dir/src/qtutil/matchview/matchmanagement.cpp.o
[ 76%] Building CXX object modules/cvv/CMakeFiles/opencv_cvv.dir/src/qtutil/matchview/matchportionselector.cpp.o
[ 76%] Building CXX object modules/aruco/CMakeFiles/opencv_aruco.dir/src/aruco.cpp.o
[ 77%] Linking CXX shared library ../../lib/libopencv_xobjdetect.so
[ 77%] Building CXX object modules/cvv/CMakeFiles/opencv_cvv.dir/src/qtutil/matchview/matchscene.cpp.o
[ 77%] Built target opencv_xobjdetect
[ 77%] Processing OpenCL kernels (bioinspired)
Scanning dependencies of target opencv_bioinspired
[ 78%] Building CXX object modules/bioinspired/CMakeFiles/opencv_bioinspired.dir/src/basicretinafilter.cpp.o
[ 78%] Building CXX object modules/rgbd/CMakeFiles/opencv_rgbd.dir/src/dynafu_tsdf.cpp.o
[ 78%] Building CXX object modules/cvv/CMakeFiles/opencv_cvv.dir/src/qtutil/matchview/matchselectionselector.cpp.o
[ 78%] Building CXX object modules/cvv/CMakeFiles/opencv_cvv.dir/src/qtutil/matchview/matchsettingsselector.cpp.o
But when this is build bij docker-hub I get the follow error. Tried it already twice by triggering a build again, but doesn't help.
[ 77%] Generating qrc_window_QT.cpp
[91mRCC: Error in '/opencv/opencv/modules/highgui/src/window_QT.qrc': Cannot find file 'files_Qt/Milky/48/28.png'
[0m
[91mmake[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/build.make:78: modules/highgui/qrc_window_QT.cpp] Error 1
[0m
[91mmake[1]: *** [CMakeFiles/Makefile2:4375: modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
[0m
[91mmake: *** [Makefile:163: all] Error 2
[0m
Removing intermediate container 7f068cac93e1
The command '/bin/sh -c make -j$(nproc)' returned a non-zero code: 2
I have checked opencv on git https://github.com/opencv/opencv/tree/4.3.0/modules/highgui/src/files_Qt/Milky/48 where that file is available.
Update 15-04-2020
I have now executed the same file not on my windows system but on my linux environment which also has docker. This is running debian 9.12 and Docker version 19.03.8. Also on this system the build is completed successfully. Yesterday I started it again on docker-hub and again same error.
Anyone what I do wrong?

OpenPose linking error on std::thread

So trying to build OpenPose from source, and was running into a linking problem. Current environment is Ubuntu 16.04.4. OpenCV version is 3.3.1. GCC version is 5.4.0.
[ 87%] Built target openpose
[ 87%] Linking CXX executable 1_extract_from_image.bin
[ 87%] Linking CXX executable openpose.bin
[ 87%] Linking CXX executable 3_user_input_processing_and_output.bin
[ 87%] Linking CXX executable 2_extract_pose_or_heatmat_from_image.bin
[ 87%] Linking CXX executable 1_custom_post_processing.bin
[ 87%] Linking CXX executable 2_user_processing_function.bin
[ 88%] Linking CXX executable 1_openpose_read_and_display.bin
/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/libopencv_objdetect.so.3.3.1: undefined reference to std::thread::_State::~_State()#GLIBCXX_3.4.22
/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/libopencv_objdetect.so.3.3.1: undefined reference to std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())#GLIBCXX_3.4.22
/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/libopencv_objdetect.so.3.3.1: undefined reference to typeinfo for std::thread::_State#GLIBCXX_3.4.22
collect2: error: ld returned 1 exit status
examples/openpose/CMakeFiles/openpose.bin.dir/build.make:150: recipe for target 'examples/openpose/openpose.bin' failed
make[2]: *** [examples/openpose/openpose.bin] Error 1
CMakeFiles/Makefile2:1135: recipe for target 'examples/openpose/CMakeFiles/openpose.bin.dir/all' failed
make[1]: *** [examples/openpose/CMakeFiles/openpose.bin.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
I just had the same issue and installed the latest versions of gcc and g++, which solved the problem. Like here:
https://askubuntu.com/a/789417
I just installed version 8 (thus gcc-8 and g++-8). Then you have to call update-alternatives as described there.

Overcoming "undefined reference" error in cmake - a package is being requested by cmake and I have the package available

cmake says I have an undefined reference to gzopen64#ZLIB_1.2.3.3. I built zlib 1.2.3.3 from source, added the include directory to CPATH, added the lib directory to LD_LIBRARY_PATH, and pasted libz.so.1.2.3.3 into my build directory. I am still stuck on this error. Is there any other way I can lead cmake to the zlib 1.2.3.3 build?
Edit
OK here's the full error message:
$ make
Scanning dependencies of target utilscore
[ 4%] Building CXX object src/core/CMakeFiles/utilscore.dir/CFDMesh.cpp.o
[ 8%] Linking CXX static library libutilscore.a
[ 8%] Built target utilscore
Scanning dependencies of target nalu_preprocess
[ 13%] Building CXX object src/preprocessing/CMakeFiles/nalu_preprocess.dir/PreProcessingTask.cpp.o
[ 17%] Building CXX object src/preprocessing/CMakeFiles/nalu_preprocess.dir/NDTW2D.cpp.o
[ 21%] Building CXX object src/preprocessing/CMakeFiles/nalu_preprocess.dir/SamplingPlanes.cpp.o
[ 26%] Building CXX object src/preprocessing/CMakeFiles/nalu_preprocess.dir/ABLFields.cpp.o
[ 30%] Building CXX object src/preprocessing/CMakeFiles/nalu_preprocess.dir/ChannelFields.cpp.o
[ 34%] Building CXX object src/preprocessing/CMakeFiles/nalu_preprocess.dir/RotateMesh.cpp.o
[ 39%] Building CXX object src/preprocessing/CMakeFiles/nalu_preprocess.dir/BdyIOPlanes.cpp.o
[ 43%] Building CXX object src/preprocessing/CMakeFiles/nalu_preprocess.dir/PreProcessDriver.cpp.o
[ 47%] Building CXX object src/preprocessing/CMakeFiles/nalu_preprocess.dir/nalu_preprocess.cpp.o
[ 52%] Linking CXX executable nalu_preprocess
CMakeFiles/nalu_preprocess.dir/BdyIOPlanes.cpp.o: In function `stk::mesh::Bucket::begin_nodes(unsigned long) const':
/projects/windsim/exawind/SharedSoftwareA/spack/opt/spack/linux-centos6-x86_64/gcc-5.2.0/trilinos-develop-aeyspdjmeoo5inhcb7cpaojmrds7f6tt/include/stk_mesh/base/Bucket.hpp:306: undefined reference to `stk::mesh::Bucket::check_for_invalid_connectivity_request(stk::mesh::ConnectivityType const*) const'
/projects/windsim/exawind/SharedSoftwareA/spack/opt/spack/linux-centos6-x86_64/gcc-5.2.0/libxml2-2.9.4-ek3x27doaf3vg2izm363k755zy7nd67z/lib/libxml2.so.2: undefined reference to `gzopen64#ZLIB_1.2.3.3'
collect2: error: ld returned 1 exit status
make[2]: *** [src/preprocessing/nalu_preprocess] Error 1
make[1]: *** [src/preprocessing/CMakeFiles/nalu_preprocess.dir/all] Error 2
I understand there are similar questions about undefined reference errors. I'm not convinced this is a duplicate question. This answer nicely lays out all the possible causes of an undefined reference. I didn't find one that matched my specific situation, where a package is being requested by cmake and I have the package available.