I am trying to install openCv on ubuntu 18.0
I have followed steps of this blog
But when I run this command
make
it throws the following error
[ 57%] Built target opencv_perf_ocl
[ 57%] Built target opencv_nonfree
[ 57%] Built target opencv_perf_nonfree
[ 58%] Built target opencv_test_nonfree
[ 58%] Building CXX object modules/contrib/CMakeFiles/opencv_contrib.dir/src/chamfermatching.cpp.o
/home/knoldus/opencv-2.4.9/modules/contrib/src/chamfermatching.cpp: In member function ‘void cv::ChamferMatcher::Matching::computeDistanceTransform(cv::Mat&, cv::Mat&, cv::Mat&, float, float, float)’:
/home/knoldus/opencv-2.4.9/modules/contrib/src/chamfermatching.cpp:969:30: error: the compiler can assume that the address of ‘annotate_img’ will never be NULL [-Werror=address]
if (&annotate_img!=NULL) {
^
/home/knoldus/opencv-2.4.9/modules/contrib/src/chamfermatching.cpp:1016:34: error: the compiler can assume that the address of ‘annotate_img’ will never be NULL [-Werror=address]
if (&annotate_img!=NULL) {
^
/home/knoldus/opencv-2.4.9/modules/contrib/src/chamfermatching.cpp: In member function ‘cv::ChamferMatcher::Match* cv::ChamferMatcher::Matching::localChamferDistance(cv::Point, cv::Mat&, cv::Mat&, cv::ChamferMatcher::Template*, float)’:
/home/knoldus/opencv-2.4.9/modules/contrib/src/chamfermatching.cpp:1111:25: error: the compiler can assume that the address of ‘orientation_img’ will never be NULL [-Werror=address]
if (&orientation_img!=NULL) {
^
/home/knoldus/opencv-2.4.9/modules/contrib/src/chamfermatching.cpp:1111:5: warning: nonnull argument ‘orientation_img’ compared to NULL [-Wnonnull-compare]
if (&orientation_img!=NULL) {
^~
/home/knoldus/opencv-2.4.9/modules/contrib/src/chamfermatching.cpp: In member function ‘void cv::ChamferMatcher::Matching::computeDistanceTransform(cv::Mat&, cv::Mat&, cv::Mat&, float, float, float)’:
/home/knoldus/opencv-2.4.9/modules/contrib/src/chamfermatching.cpp:1016:17: warning: nonnull argument ‘annotate_img’ compared to NULL [-Wnonnull-compare]
if (&annotate_img!=NULL) {
^~
/home/knoldus/opencv-2.4.9/modules/contrib/src/chamfermatching.cpp:969:13: warning: nonnull argument ‘annotate_img’ compared to NULL [-Wnonnull-compare]
if (&annotate_img!=NULL) {
^~
cc1plus: some warnings being treated as errors
modules/contrib/CMakeFiles/opencv_contrib.dir/build.make:158: recipe for target 'modules/contrib/CMakeFiles/opencv_contrib.dir/src/chamfermatching.cpp.o' failed
make[2]: *** [modules/contrib/CMakeFiles/opencv_contrib.dir/src/chamfermatching.cpp.o] Error 1
CMakeFiles/Makefile2:2974: recipe for target 'modules/contrib/CMakeFiles/opencv_contrib.dir/all' failed
make[1]: *** [modules/contrib/CMakeFiles/opencv_contrib.dir/all] Error 2
Makefile:151: recipe for target 'all' failed
make: *** [all] Error 2
Installing old versions of opencv can cause a lot problems as stated in this question (check comments).
Solution for Cmake errors regarding detection of CXXCompiler can be
found here
Solution for fatal error: stdlib.h: No such file or directory can
be found here
Solution for the make error stated in the latest edition of the
question can be found in the patch here
Related
I am currently installing OpenCV3.4.4 in ordre to use it with Code::Blocks. I used CMake GUI to Configure and Generates the binaries.
But when I'm using 'mingw32-make' to finish the installation, an error occurs about strnlen which apparently is not define. I have the following message :
"
C:\opencv\sources\modules\core\src\persistence.cpp: In function 'char* icvGets(CvFileStorage*, char*, int)':
C:\opencv\sources\modules\core\src\persistence.cpp:71:46: error: 'strnlen' was not declared in this scope
size_t sz = strnlen(ptr, maxCount);
^
C:\opencv\sources\modules\core\src\persistence.cpp:82:46: error: 'strnlen' was not declared in this scope
size_t sz = strnlen(ptr, maxCount);
^
modules\core\CMakeFiles\opencv_core.dir\build.make:901: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/src/persistence.cpp.obj' failed
mingw32-make[2]: * [modules/core/CMakeFiles/opencv_core.dir/src/persistence.cpp.obj] Error 1
CMakeFiles\Makefile2:1671: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/all' failed
mingw32-make[1]: * [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
Makefile:161: recipe for target 'all' failed
mingw32-make: *** [all] Error 2"
"
I've read some other forum asking to change some variables in CMake GUI but for other issues and I did not succeed to find the same as me. I hope that someone could help me. thank you
If this is useful for you, I was able to compile OpenCV 3.1.0 with MinGW32.
I have not been able to compile OpenCV3.4.7 with MinGW32 (I think that this backward compatibility has been abandoned), but I succeeded to compile OpenCV3.4.7 with MinGW64.
Hello I' ve got issue on caffe installation. I did everything in accordance to the instruction https://github.com/BVLC/caffe/wiki/Ubuntu-16.04-Installation-Guide (for CPU version)
On command make all I've got the following output:
CXX src/caffe/util/io.cpp
In file included from /usr/local/include/opencv2/core.hpp:52:0,
from /usr/local/include/opencv2/core/core.hpp:48,
from src/caffe/util/io.cpp:6:
/usr/local/include/opencv2/core/cvdef.h:421:4: error: #error "OpenCV 4.x+ requires enabled C++11 support"
# error "OpenCV 4.x+ requires enabled C++11 support"
^
In file included from /usr/include/c++/5/array:35:0,
from /usr/local/include/opencv2/core/cvdef.h:426,
from /usr/local/include/opencv2/core.hpp:52,
from /usr/local/include/opencv2/core/core.hpp:48,
from src/caffe/util/io.cpp:6:
/usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support \
^
In file included from /usr/local/include/opencv2/core/base.hpp:58:0,
from /usr/local/include/opencv2/core.hpp:54,
from /usr/local/include/opencv2/core/core.hpp:48,
from src/caffe/util/io.cpp:6:
/usr/local/include/opencv2/core/cvstd.hpp:389:12: error: expected ‘,’ or ‘...’ before ‘&&’ token
Ptr(Ptr&& o);
^
/usr/local/include/opencv2/core/cvstd.hpp:389:16: error: invalid constructor; you probably meant ‘cv::Ptr<T> (const cv::Ptr<T>&)’
Ptr(Ptr&& o);
^
/usr/local/include/opencv2/core/cvstd.hpp:390:25: error: expected ‘,’ or ‘...’ before ‘&&’ token
Ptr& operator = (Ptr&& o);
^
In file included from /usr/local/include/opencv2/core/cvstd.hpp:1033:0,
from /usr/local/include/opencv2/core/base.hpp:58,
from /usr/local/include/opencv2/core.hpp:54,
from /usr/local/include/opencv2/core/core.hpp:48,
from src/caffe/util/io.cpp:6:
/usr/local/include/opencv2/core/ptr.inl.hpp:256:16: error: expected ‘,’ or ‘...’ before ‘&&’ token
Ptr<T>::Ptr(Ptr&& o) : owner(o.owner), stored(o.stored)
^
/usr/local/include/opencv2/core/ptr.inl.hpp:256:1: error: prototype for ‘cv::Ptr<T>::Ptr(cv::Ptr<T>)’ does not match any in class ‘cv::Ptr<T>’
Ptr<T>::Ptr(Ptr&& o) : owner(o.owner), stored(o.stored)
^
In file included from /usr/local/include/opencv2/core/base.hpp:58:0,
from /usr/local/include/opencv2/core.hpp:54,
from /usr/local/include/opencv2/core/core.hpp:48,
from src/caffe/util/io.cpp:6:
/usr/local/include/opencv2/core/cvstd.hpp:319:5: error: candidates are: template<class T> template<class Y> cv::Ptr<T>::Ptr(const cv::Ptr<Y>&, T*)
Ptr(const Ptr<Y>& o, T* p);
Here is also a lot of text in output but I cannot upload it because of limit on number of characters
Makefile:591: recipe for target '.build_release/src/caffe/util/io.o' failed
make: *** [.build_release/src/caffe/util/io.o] Error 1
Can somebody help me with this problem?
OS: Ubuntu 16.04
cmake version 3.5.1
Cuda version: 10.0.130
The problem was in 4th version of OpenCV. Caffe dosen't work with it. When I installed 3rd version everything was ok.
I've got an error. The error is occurred in cmd directory where openCV is when I use the command mingw32-make. My OS is win 7 64 bit. I followed this user guide:
http://www.ti.com/lit/ug/dlpu042/dlpu042.pdf
Any help is appreciated!Here is the error in cmd:
C:\OpenCV>mingw32-make
[ 0%] Built target gen-pkgconfig
[ 2%] Built target zlib
[ 5%] Built target libjpeg-turbo
[ 8%] Built target libtiff
[ 16%] Built target libwebp
[ 19%] Built target libjasper
[ 20%] Built target libpng
[ 25%] Built target IlmImf
[ 25%] Building CXX object 3rdparty/protobuf/CMakeFiles/libprotobuf.dir/src/goog
le/protobuf/stubs/io_win32.cc.obj
C:\Users\xxx\Downloads\opencv\sources\3rdparty\protobuf\src\google\protobuf
\stubs\io_win32.cc:94:3: warning: identifier 'nullptr' is a keyword in C++11 [-W
c++0x-compat]
return s == nullptr || *s == 0;
^
C:\Users\xxx\Downloads\opencv\sources\3rdparty\protobuf\src\google\protobuf
\stubs\io_win32.cc: In function 'bool google::protobuf::internal::win32::{anonym
ous}::null_or_empty(const char_type*)':
C:\Users\xxx\Downloads\opencv\sources\3rdparty\protobuf\src\google\protobuf
\stubs\io_win32.cc:94:15: error: 'nullptr' was not declared in this scope
return s == nullptr || *s == 0;
^
C:\Users\xxx\Downloads\opencv\sources\3rdparty\protobuf\src\google\protobuf
\stubs\io_win32.cc: In function 'bool google::protobuf::internal::win32::{anonym
ous}::null_or_empty(const char_type*) [with char_type = char]':
C:\Users\xxx\Downloads\opencv\sources\3rdparty\protobuf\src\google\protobuf
\stubs\io_win32.cc:95:1: error: control reaches end of non-void function [-Werro
r=return-type]
}
^
C:\Users\xxx\Downloads\opencv\sources\3rdparty\protobuf\src\google\protobuf
\stubs\io_win32.cc: In function 'bool google::protobuf::internal::win32::{anonym
ous}::null_or_empty(const char_type*) [with char_type = wchar_t]':
C:\Users\xxx\Downloads\opencv\sources\3rdparty\protobuf\src\google\protobuf
\stubs\io_win32.cc:95:1: error: control reaches end of non-void function [-Werro
r=return-type]
}
^
cc1plus.exe: some warnings being treated as errors
3rdparty\protobuf\CMakeFiles\libprotobuf.dir\build.make:258: recipe for target '
3rdparty/protobuf/CMakeFiles/libprotobuf.dir/src/google/protobuf/stubs/io_win32.
cc.obj' failed
mingw32-make[2]: *** [3rdparty/protobuf/CMakeFiles/libprotobuf.dir/src/google/pr
otobuf/stubs/io_win32.cc.obj] Error 1
CMakeFiles\Makefile2:715: recipe for target '3rdparty/protobuf/CMakeFiles/libpro
tobuf.dir/all' failed
mingw32-make[1]: *** [3rdparty/protobuf/CMakeFiles/libprotobuf.dir/all] Error 2
Makefile:161: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
I'm trying to build opencv-2.4.10 on my Raspberry Pi model B (wheezy) following these instructions but am getting the error below. What's the best way of fixing this?
[ 14%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/grfmt_jpeg2000.cpp.o
In file included from /usr/include/jasper/jasper.h:77:0,
from /home/pi/opencv-2.4.10/modules/highgui/src/grfmt_jpeg2000.cpp:58:
/usr/include/jasper/jas_math.h: In function ‘int jas_safe_size_mul(size_t, size_t, size_t*)’:
/usr/include/jasper/jas_math.h:117:22: error: ‘SIZE_MAX’ was not declared in this scope
modules/highgui/CMakeFiles/opencv_highgui.dir/build.make:422: recipe for target 'modules/highgui/CMakeFiles/opencv_highgui.dir/src/grfmt_jpeg2000.cpp.o' failed
make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/grfmt_jpeg2000.cpp.o] Error 1
CMakeFiles/Makefile2:1772: recipe for target 'modules/highgui/CMakeFiles/opencv_highgui.dir/all' failed
make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
Makefile:133: recipe for target 'all' failed
make: *** [all] Error 2
I'm not sure if its best practice but after trying to correct by defining __STDC_LIMIT_MACROS, I gave up and edited /usr/include/jasper/jas_math.h, adding
#if ! defined SIZE_MAX
#define SIZE_MAX (4294967295U)
#endif
right after
#include <stdint.h>
I was following this example and received the following error when running make
In file included from /root/src/opencv-3.1.0/modules/videoio/src/cap_ffmpeg.cpp:45:0:
/root/src/opencv-3.1.0/modules/videoio/src/cap_ffmpeg_impl.hpp: In member function ‘bool OutputMediaStream_FFMPEG::open(const char*, int, int, double)’:
/root/src/opencv-3.1.0/modules/videoio/src/cap_ffmpeg_impl.hpp:2207:41: warning: ignoring return value of ‘int avformat_write_header(AVFormatContext*, AVDictionary**)’, declared with attribute warn_unused_result [-Wunused-result]
avformat_write_header(oc_, NULL);
^
Linking CXX shared library ../../lib/libopencv_videoio.so
/usr/bin/ld: /usr/local/lib/libx264.a(common.o): relocation R_ARM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libx264.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
modules/videoio/CMakeFiles/opencv_videoio.dir/build.make:215: recipe for target 'lib/libopencv_videoio.so.3.1.0' failed
make[2]: *** [lib/libopencv_videoio.so.3.1.0] Error 1
CMakeFiles/Makefile2:4058: recipe for target 'modules/videoio/CMakeFiles/opencv_videoio.dir/all' failed
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
Makefile:147: recipe for target 'all' failed
make: *** [all] Error 2
I have successfully installed opencv on Raspberry Pi 3 by following the steps in the link http://www.pyimagesearch.com/2015/02/23/install-opencv-and-python-on-your-raspberry-pi-2-and-b/
The changes i made while following the steps are:
Use 'aptitude' instead of 'apt-get' and accept all recommendations given
Before following Step 11, run 'source ~/.profile'. To quit, run 'deactivate'
Hope this helps :)