OpenCV 3.4.4 make error with mingw32-make "persistence.cpp" - opencv

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.

Related

Error building opencv with cmake on raspberry pi

I'm trying to build opencv-3.4.0 (with opencv_contrib-3.4.0) on Raspberry Pi. I'm getting a cmake build error after a 99 % , what should I change?
After I tried "make -j4" in the opencv-3.4.0/build folder, it successfully completed its process until 99%. Before that, configuration and generation part is done with cmake-gui.
Here is the error I am getting on the terminal
make[2]: *** [modules/python3/CMakeFiles/opencv_python3.dir/build.make:63: modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:4018: modules/python3/CMakeFiles/opencv_python3.dir/all] Error 2
make: *** [Makefile:163: all] Error 2
What could be the problem?
Edit the file /home/pi/opencv-3.4.0/modules/python/src2/cv2.cpp and change
char* str = PyString_AsString(obj);
to const char* str = PyString_AsString(obj);
A slightly sideways answer, but I found that version 4.1 (without contribs - haven't tried it with) builds with no problems

SIZE_MAX not declared when trying to build opencv-2.4.10 on raspbian wheezy

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>

Error building opencv on a raspberry pi 3

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 :)

Compilation of OpenCV 3.1.0 videoio error

Im trying to compile Opencv 3.1.0 with MingW 4.9.2 but i have the follow error
modules\videoio\CMakeFiles\opencv_videoio.dir\build.make:187: recipe for target
'modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_dshow.cpp.obj' failed
mingw32-make[2]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_dsho
w.cpp.obj] Error 1
CMakeFiles\Makefile2:4340: recipe for target 'modules/videoio/CMakeFiles/opencv_
videoio.dir/all' failed
mingw32-make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
makefile:159: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
I found that is a OpenCV build error during cap_dshow.cpp build. The solution showed here is no necessary because the file in Opencv 3.1 is already fixed.
During Cmake phase i've changed this (trough Cmake GUI 3.4.3), but doesnt work
CMAKE_BUILD_TYPE = Debug
WITH_EIGEN = 0
WITH_OPENGL = 0
WITH_IPP = 0
WITH_QT = 1
I've tried the solution given in this post, but doesnt work neither
add_extra_compiler_option(-Werror=non-virtual-dtor)
My intention is work with C++, Opencv and the GUI designer of QT. I have installed the library qt-5.4.0-x64-mingw492r0-sjlj, it comes with its own MingW 4.9.2.
(PS/for another proyect i've compiled Opencv3.1.0 with Mingw 4.9.3 and its works perfectly)
Can anybody helpme please!!!
In file %OPENCV_HOME%\sources\modules\videoio\src\cap_dshow.cpp
Add in top:
#define STRSAFE_NO_DEPRECATE
Work for me in Qt 5.6.2, Mingw 4.9.2 OpenCV 3.2.0

Error installing opencv-3.0.0-beta on Ubuntu 14.04

I am new to opencv and i am trying to install opencv-3.0.0-beta on ubuntu 14.04. When running make command, I get an error at 54%.I followed the same steps mentioned in http://docs.opencv.org/trunk/doc/tutorials/introduction/linux_install/linux_install.html. but I still get an error.
Below is the error message I'm getting.
/usr/bin/ld:
../../../3rdparty/ippicv/unpack/ippicv_lnx/lib/ia32/libippicv.a(jmp_ippiResizeGetBufferSize_16s_as.s.o):
relocation R_386_GOTOFF against undefined symbol
`ippicvJumpIndexForMergedLibs' can not be used when making a shared
object /usr/bin/ld: final link failed: Bad value collect2: error: ld
returned 1 exit status make[2]: * [lib/libopencv_imgproc.so.3.0.0]
Error 1 make1: [modules/imgproc/CMakeFiles/opencv_imgproc.dir/all]
Error 2 make: ** [all] Error 2
Please help in solving it.
Thanks
It looks like your IPP configuration bugs. If you don't need IPP, you might want to rerun the cmake command with this option WITH_IPP=OFF.
Further reading here about deactivate IPP and here to properly configure IPP.

Resources