Makefile:160: recipe for target 'all' failed - opencv

Guys am trying to install OpenCV 3.3.1 on Raspbian stretch Noobs on Pi model B
I am following this tutorial.
But when i type
cmake
-D CMAKE_BUILD_TYPE=RELEASE \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_EXTRA_MODULES_PATH= ~/Opencv_contrib-3.3.1/modules \
-D BUILD_opencv_python3=yes \
-D BUILD_EXAMPLES=ON \
-D WITH_CUDA=OFF.. `
And then i type make -j2
To get this error
[ 7%] building cxx object 3rsparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ ImfZipcompressor.cpp.o
[ 7%] linking cxx static library.. /lib/libIlmImf.a
[ 7%] built target IlmImf
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2
What's the problem?

I found that the problem was in this line
/home/pi/opencv3.3.1/3rdparty/carotene/src/absdiff.cpp:42:22: fatal error: common.hpp: no such file or directory
#include "common.hpp"
I 've gone through the directory and opened absdiff.cpp to find #include "common.hpp"
But no file called common.hpp in the same directory so i copied common.hpp from
/home/pi/opencv/3rd party/carotene/src/
Which i cloned using this code
git clone https://github.com/Itseez/opencv.git opencv
I don't know why opencv-3.3.1 doesn't have it or just an issue during the download...
Or just re-download opencv-3.3.1 again

Related

opencv2/intensity_transform.hpp: No such file or directory

I'm quite a noob using cmake and compilers, I have compiled opencv-4.4.0 with contrib on my desktop, while facing the issue opencv2/intensity_transform.hpp: No such file or directory when I'm trying to include such file using:
#include <iostream>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/intensity_transform.hpp>
#include <opencv2/imgproc.hpp>
#include "opencv2/imgcodecs.hpp"
The opencv is installed to default /usr/local directory, so opencv2 could be found in /usr/local/include/ directory. Only intensity_transform failed, with error message:
Scanning dependencies of target srobot
[ 25%] Building CXX object src/CMakeFiles/srobot.dir/img_aug_OPENCV/image_enhance_by_opencv.cpp.o
${ROOD_DIR}/src/img_aug_OPENCV/image_enhance_by_opencv.cpp:4:10: fatal error: opencv2/intensity_transform.hpp: No such file or directory
#include <opencv2/intensity_transform.hpp>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
src/CMakeFiles/srobot.dir/build.make:62: recipe for target 'src/CMakeFiles/srobot.dir/img_aug_OPENCV/image_enhance_by_opencv.cpp.o' failed
make[2]: *** [src/CMakeFiles/srobot.dir/img_aug_OPENCV/image_enhance_by_opencv.cpp.o] Error 1
CMakeFiles/Makefile2:85: recipe for target 'src/CMakeFiles/srobot.dir/all' failed
make[1]: *** [src/CMakeFiles/srobot.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
Here is the CMakeLists.txt:
# CMakeLists from src directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
add_definitions(-DUSE_OPENCV)
# using mkl/cuda
set(MKL_DIR /opt/intel/mkl)
set(CUDA_DIR /usr/local/cuda)
include_directories(${MKL_DIR}/include ${CUDA_DIR}/include ${PROJECT_SOURCE_DIR}/src)
link_directories(${MKL_DIR}/lib/intel64 ${CUDA_DIR}/lib64)
# this command recursively add *.cpp files in src and add them to list: srcs
file(GLOB_RECURSE srcs ${PROJECT_SOURCE_DIR}/src/img_aug_OPENCV/image_enhance_by_opencv.cpp)
message(STATUS "PROJECT_SOURCE_DIR: " ${PROJECT_SOURCE_DIR})
message(STATUS "srcs: " ${srcs})
add_library(srobot SHARED ${srcs})
set(OPENCV_LIBS opencv_core opencv_imgproc opencv_imgcodecs)
target_link_libraries(srobot mkl_core ${OPENCV_LIBS})
Actually I'm facing this with original opencv-3.5.4, it is also installed from source. Here is the cmake commands I used:
cmake \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D WITH_CUDA=ON \
-D BUILD_opencv_cudacodec=OFF \
-D ENABLE_PRECOMPILED_HEADERS=OFF\
-D ENABLE_FAST_MATH=1 \
-D CUDA_FAST_MATH=1 \
-D WITH_CUBLAS=1 \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=ON \
-D OPENCV_ENABLE_NONFREE=ON \
-D OPENCV_EXTRA_MODULES_PATH=/home/ubuntu/Installation/opencv_contrib-4.4.0/modules/ \
-D PYTHON_EXECUTABLE=/home/ubuntu/anaconda3/envs/tf2/bin/python \
-D BUILD_TIFF=ON ..
And system info:
Ubuntu 18.04;
CUDA 10.0.0;
I will provide more sys info if necessary. Is this related to platform? It seems that source code was from Windows platform. Help needed!

How to fix make errors on ubuntu 16.04

Try to dockerize bitcoin-sv on ubuntu:16.04, but have an error on last step.
A piece of Dockerfile :
RUN mkdir boost \
&& cd boost \
&& wget https://dl.bintray.com/boostorg/release/1.70.0/source/boost_1_70_0.tar.gz \
&& tar -xzvf boost_1_70_0.tar.gz \
&& cd boost_1_70_0 \
&& ./bootstrap.sh \
&& ./b2 \
&& ./b2 install \
&& cd ../../ \
&& git clone https://github.com/bitcoin-sv/bitcoin-sv \
&& cd bitcoin-sv \
&& ./autogen.sh \
&& mkdir build \
&& cd build \
&& ../configure \
&& make <------------- error on this final step
Error:
Makefile:4415: recipe for target 'rpc/libbitcoin_cli_a-client.o' failed
make[2]: *** [rpc/libbitcoin_cli_a-client.o] Error 1
make[2]: Leaving directory '/bitcoin-sv/build/src'
Makefile:8455: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/bitcoin-sv/build/src'
Makefile:660: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1
Read here that there may be a lack of memory . How to fixed it?
One more error logged. There is out of memory in docker machine
../../src/validation.cpp:4046:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
cacheSize > std::max(static_cast<uint64_t>((9 * nTotalSpace) / 10),
~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nTotalSpace - MAX_BLOCK_COINSDB_USAGE * ONE_MEBIBYTE);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
g++: internal compiler error: Killed (program cc1plus)
The error g++: internal compiler error: Killed (program cc1plus) is nearly always due to too little memory - as explained more thoroughly in this StackOverflow post by Jon.
Running on ubuntu (not meaning within a virtual machine on ubuntu) your machine may be out of memory as docker has access to the whole memory of a Linux host as far as I know. If running within a virtual machine make sure it has enough memory available and in turn that it is available to docker.
For macOS or Windows, you could easily manage the resources available to docker (assuming that there are still resources left) by following Roberts answer to the (not quite correctly phrased) StackOverflow question 'How to assign more memory to docker container'.

Build fails during make of OpenCV on Raspberry Pi with "segmentation fault" caused by "cc1plus"

I'm trying to make a build of OpenCV 4.0.0 on my Raspberry Pi 3B+, and keep running into this issue:
[ 83%] Building CXX object modules/stitching/CMakeFiles/opencv_perf_stitching.dir/perf/opencl/perf_stitch.cpp.o
c++: internal compiler error: Segmentation fault (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
modules/stitching/CMakeFiles/opencv_perf_stitching.dir/build.make:62: recipe for target 'modules/stitching/CMakeFiles/opencv_perf_stitching.dir/perf/opencl/perf_stitch.cpp.o' failed
make[2]: *** [modules/stitching/CMakeFiles/opencv_perf_stitching.dir/perf/opencl/perf_stitch.cpp.o] Error 4
CMakeFiles/Makefile2:23142: recipe for target 'modules/stitching/CMakeFiles/opencv_perf_stitching.dir/all' failed
make[1]: *** [modules/stitching/CMakeFiles/opencv_perf_stitching.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2
This is the make/build portion of the script I'm running:
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_ENABLE_NONFREE=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
-D PYTHON_EXECUTABLE=~/.virtualenvs/py3cv4/bin/python \
-D WITH_GSTREAMER=ON \
-D WITH_FFMPEG=ON \
-D WITH_OPENMP=ON \
-D BUILD_EXAMPLES=ON ..
echo ""
echo "======================="
echo "Building OpenCV..."
make -j4
sudo make install
sudo ldconfig
I read somewhere that I should change the make -j4 command to not use all four cores, because I'm running out of memory. I tried make -j1, but still got the same error at the same spot. I'm going to try again with just plain make, but delete all the pre-built stuff that's in there and start over from scratch to see if that helps.
Turns out I needed to entirely delete the build I had created and rebuild it with a single core instead of all four, as it was using up too much memory. I deleted my /opencv/build/ directory and then did make with no -j command, and it worked fine. It took a really long time (5+ hours), but it did complete successfully. Now I just have to figure out why I can't import cv2...

Torch OpenCV integration

I want to install opencv package in torch. I have already installed opencv and it is working fine. After using luarocks install cv for installing cv package in torch I am getting following error.
CMake Error at CMakeLists.txt:30 (FIND_PACKAGE):
Could not find a configuration file for package "OpenCV" that exactly
matches requested version "3.1".
The following configuration files were considered but not accepted:
/home/user/opencv-3.1.0/cmake/OpenCVConfig.cmake, version: unknown
/usr/local/share/OpenCV/OpenCVConfig.cmake, version: 3.3.0
-- Configuring incomplete, errors occurred!
See also "/tmp/luarocks_cv-scm-1-5467/torch-
opencv/build/CMakeFiles/CMakeOutput.log".
make: *** No targets specified and no makefile found. Stop.
Is there any way to fix this?
you may take a look at installation guide from the GitHub page
torch-opencv requires opencv-3.1.0 and is not (yet) compatible with opencv-3.3.0.
Therefore, you need to install opencv-3.1.0
git clone https://github.com/daveselinger/opencv
cd opencv
git checkout 3.1.0-with-cuda8
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local
-D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON
-D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON
-D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
make
sudo make install
luarocks install cv
if your cuda version is not 8, you should change it.

OpenCV 2.4.13 for C++ compilation under ubuntu fails

I am trying to install openCV for C++ on ubuntu. I am using this document . But step of compilation fails. The log of make is as follow:
$make
[ 0%] Built target opencv_core_pch_dephelp
[ 0%] Built target pch_Generate_opencv_core
[ 3%] Built target opencv_core
[ 4%] Built target opencv_ts_pch_dephelp
[ 4%] Built target pch_Generate_opencv_ts
[ 4%] Built target opencv_flann_pch_dephelp
[ 5%] Built target pch_Generate_opencv_flann
[ 5%] Built target opencv_flann
[ 5%] Built target opencv_imgproc_pch_dephelp
[ 5%] Built target pch_Generate_opencv_imgproc
[ 9%] Built target opencv_imgproc
[ 9%] Automoc for target opencv_highgui
[ 9%] Built target opencv_highgui_automoc
[ 9%] Automoc for target opencv_highgui_pch_dephelp
[ 9%] Built target opencv_highgui_pch_dephelp_automoc
[ 9%] Built target opencv_highgui_pch_dephelp
[ 9%] Built target pch_Generate_opencv_highgui
[ 9%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir /src/window_QT.cpp.o
In file included from /home/src/OpenCV/opencv-2.4.13/modules/highgui/src/window_QT.cpp:47:0:
/home/src/OpenCV/opencv-2.4.13/modules/highgui/src/window_QT.h:46:20: fatal error: QtOpenGL: No such file or directory
#include <QtOpenGL>
^
compilation terminated.
make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/window_QT.cpp.o] Error 1
make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
make: *** [all] Error 2
Could you please help me to fix this compilation problem?
I avoided the compilation error by runnuing:
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_QT=ON -D WITH_OPENGL=ON ..
Instead of :
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..

Resources