3
votes

The following code compiles with no error, but when I try to execute it i got "The procedure entry point _ZSt24__throw_out_of_range_fmtPKcz could not be located in the dynamic link library libopencv_core2413.dll", original message in portuguese.

#include "opencv2/highgui.hpp"
#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/opencv.hpp"
#include "opencv2/opencv_modules.hpp"

int main()
{
  cv::Mat a;
  return 0;
}

Well, initially I built it from the source, downloaded at the sourceforge link https://sourceforge.net/projects/opencvlibrary/ The cmake version is 3.5.0-rc2, the mingw version is 4.9.3, the opencv version is 2.4.13. I have installed the ghc for haskell and allegro5 libraries on my mingw.

After downloading it, I extracted it at C:/opencv. Using the cmake-gui I set the source folder as C:/opencv/sources and the build as C:/opencv/build. About the configuration flags, I just unmark the BUILD_opencv_pyhon, since I don't have python installed. This is the log of the configure and generate steps:

Detected version of GNU GCC: 49 (409)
CUDA compilation is disabled (due to only Visual Studio compiler supported on your platform).

General configuration for OpenCV 2.4.13 =====================================
  Version control:               unknown

  Platform:
    Host:                        Windows 10.0.10586 AMD64
    CMake:                       3.5.0-rc2
    CMake generator:             MinGW Makefiles
    CMake build tool:            C:/MinGW/bin/mingw32-make.exe
    Configuration:               Release

  C/C++:
    Built as dynamic libs?:      YES
    C++ Compiler:                C:/MinGW/bin/g++.exe  (ver 4.9.3)
    C++ flags (Release):         -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-array-bounds -Wno-aggressive-loop-optimizations -fdiagnostics-show-option -march=i686 -fomit-frame-pointer -msse -msse2 -mfpmath=sse -ffunction-sections -O2 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-array-bounds -Wno-aggressive-loop-optimizations -fdiagnostics-show-option -march=i686 -fomit-frame-pointer -msse -msse2 -mfpmath=sse -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  C:/MinGW/bin/gcc.exe
    C flags (Release):           -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -Wno-array-bounds -Wno-aggressive-loop-optimizations -fdiagnostics-show-option -march=i686 -fomit-frame-pointer -msse -msse2 -mfpmath=sse -ffunction-sections -O2 -DNDEBUG  -DNDEBUG
    C flags (Debug):             -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -Wno-array-bounds -Wno-aggressive-loop-optimizations -fdiagnostics-show-option -march=i686 -fomit-frame-pointer -msse -msse2 -mfpmath=sse -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):      
    Linker flags (Debug):        
    Precompiled headers:         YES

  OpenCV modules:
    To be built:                 core flann imgproc highgui features2d calib3d ml video legacy objdetect photo gpu ocl nonfree contrib stitching superres ts videostab
    Disabled:                    python world
    Disabled by dependency:      -
    Unavailable:                 androidcamera dynamicuda java viz

  Windows RT support:            NO

  GUI: 
    QT:                          NO
    Win32 UI:                    YES
    OpenGL support:              NO
    VTK support:                 NO

  Media I/O: 
    ZLib:                        build (ver 1.2.7)
    JPEG:                        build (ver 62)
    PNG:                         build (ver 1.5.12)
    TIFF:                        build (ver 42 - 4.0.2)
    JPEG 2000:                   build (ver 1.900.1)
    OpenEXR:                     build (ver 1.7.1)

  Video I/O:
    Video for Windows:           YES
    DC1394 1.x:                  NO
    DC1394 2.x:                  NO
    FFMPEG:                      YES (prebuilt binaries)
      codec:                     YES (ver 55.18.102)
      format:                    YES (ver 55.12.100)
      util:                      YES (ver 52.38.100)
      swscale:                   YES (ver 2.3.100)
      resample:                  NO
      gentoo-style:              YES
    OpenNI:                      NO
    OpenNI PrimeSensor Modules:  NO
    PvAPI:                       NO
    GigEVisionSDK:               NO
    DirectShow:                  YES
    Media Foundation:            NO
    XIMEA:                       NO
    Intel PerC:                  NO

  Other third-party libraries:
    Use IPP:                     NO
    Use Eigen:                   NO
    Use TBB:                     NO
    Use OpenMP:                  NO
    Use GCD                      NO
    Use Concurrency              NO
    Use C=:                      NO
    Use Cuda:                    NO
    Use OpenCL:                  YES

  OpenCL:
    Version:                     dynamic
    Include path:                C:/opencv/sources/3rdparty/include/opencl/1.2
    Use AMD FFT:                 NO
    Use AMD BLAS:                NO

  Python:
    Interpreter:                 D:/Ferramentas/[Ferramenta]_Phyton/python.exe (ver 2.7.10)

  Java:
    ant:                         NO
    JNI:                         C:/Program Files/Java/jdk1.8.0_91/include C:/Program Files/Java/jdk1.8.0_91/include/win32 C:/Program Files/Java/jdk1.8.0_91/include
    Java tests:                  NO

  Tests and samples:
    Tests:                       YES
    Performance tests:           YES
    C/C++ Examples:              NO

  Install path:                  C:/opencv/build/install

  cvconfig.h is in:              C:/opencv/build
-----------------------------------------------------------------

CMake Warning at cmake/OpenCVPackaging.cmake:23 (message):
  CPACK_PACKAGE_VERSION does not match version provided by version.hpp
  header!
Call Stack (most recent call first):
  CMakeLists.txt:1105 (include)


Configuring done
Generating done

I have tried the other versions of opencv, the most recent, the 2.4.7, and so on. Everytime I just build it and get the same error after trying execute a compiled program. I have tried to specify the compiler (I have others versions of mingw installed), for gcc C:\mingw\bin\gcc.exe and for g++ C:\mingw\bin\g++.exe. No luck, same error. I tried install a new version of mingw, and put that in C:\mingwnew and I specifyied the compiler, for gcc C:\mingwnew\bin\gcc.exe and for g++ C:\mingwnew\bin\g++.exe. No luck.

After generated, I just get to the folder c:\opencv\build and type C:\mingw\bin\mingw32-make.exe (or C:\mingwnew\bin\mingw32-make.exe in the other try). There were a few warnings about the opencv code itself (I have tried some different versions). After that, it ends up without any error. I type, C:\mingw\bin\mingw32-make.exe install. After that, I have a new folder C:\opencv\build\install\x86\mingw. In C:\opencv\build\install\x86\mingw\bin there are a few examples, tried to execute them. Same error.

Things I tried after that:

  • Copied the C:\opencv\build\install\x86\mingw folder to my mingw. Copied the libs and dlls to my project folder directory (That has no spaces in the path), copied the dlls to the system32 folder. And tried to compile with -Wall, no errors, but when try to execute, same error.

  • Compiled with

    c:/mingw/bin/g++.exe -Wall -I"C:/opencv/build/install/include" loadimg.cpp libopencv_core2413.dll.a libopencv_highgui2413.dll.a -o loadimg, trying to compile statically.

  • Compiled with

    c:/mingw/bin/g++.exe -Wall -I"C:/opencv/build/install/include" -L"C:/opencv/build/install/x86/mingw/lib" loadimg.cpp -lopencv_core2413 -lopencv_highgui2413 -o loadimg

  • Tried the dependency Walker, but got just some errors expected in using it in new SO's (windows 10), I found it in another thread here, but it gave me no clues.

  • Tried precompiled binaries of old versions of opencv. Same error.

  • Tried the mingw64, I can't even compile a hello world. Seems like it is full of bugs yet. But I think mingw32 is not the problem since I compiled other libraries before in same way with the mingw32 (allegro5), and it worked.

I searched a lot, and try a lot of things, including trying other sample codes provided by opencv docs. I can't install linux, or user another computer, so this is my only one option, and after build opencv dozen times, and after two weeks, I just can't solve the error by myself.

Any clues, or any more piece of information needed? Thanks in advance.

5
did you figure out?drerD
Not yet, I didn't stop trying to solve it. But I'm almost giving up and installing a Linux distro.Nosvan
I added the bin folder, which contains dll's, to PATH in env var setting, and then always restart my IDE or terminal which is to run the openCV program.drerD
I don't use a IDE, just sublime text and GCC, so, I may try use one. What is your IDE?Nosvan
It's just to reload environmental variable, you can restart your computer to do that. I am using MSVC 2015, restarting it seems to do the job.drerD

5 Answers

7
votes

For me work on add OPENCV_VCSVERSION = 2.4.13 (with OpenCV version 2.4.13) in OpenCVPackaging.cmake:

#in OpenCVPackaging.cmake file (line 23)
set(OPENCV_VCSVERSION "2.4.13") #<--add
set(CPACK_PACKAGE_VERSION "${OPENCV_VCSVERSION}")
2
votes

The error is in this line: General configuration for OpenCV 2.4.13

I had this error today, because there's a 3.1.0 version, but http://opencv.org/ gives you version 2.4.13 as a mismatch in their link.

So I installed the latest version from here and after this I had no more error (like the one below).

CMake Warning at cmake/OpenCVPackaging.cmake:23 (message): CPACK_PACKAGE_VERSION does not match version provided by version.hpp header! Call Stack (most recent call first): CMakeLists.txt:1105 (include)

Sorry for bad English...

0
votes

An answer on OpenCV's forum says that you cannot build the opencv_contrib modules with 2.4.

It recommends that you get the master branch from github instead. So that's what I did. (I was having trouble with the sourceforge link anyway.)

And I got no more CPACK_PACKAGE_VERSION does not match errors after that.

0
votes

As mentioned earlier, this happens when we download the code, instead of clonning using git. The easiest way is to follow the opencv documentation, and doing checkout of the desired version, before compile.

0
votes

I met the same question as yours. I put the libstdc++-6.dll of MinGW-w64 into the directory of the project, and it worked.
The solution is from here.
Actually, I still don't understand why it works. Something may get wrong in MinGW-w64.