无法使用opencv执行简单程序,错误"无法找到程序的入口点"

Nos*_*van 3 c++ 64-bit opencv mingw windows-10

以下代码编译时没有错误,但是当我尝试执行它时,我得到了" 程序入口点_ZSt24__throw_out_of_range_fmtPKcz无法位于动态链接库libopencv_core2413.dll ",原始消息是葡萄牙语.

#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;
}
Run Code Online (Sandbox Code Playgroud)

好吧,最初我是从源代码构建的,在sourceforge链接下载https://sourceforge.net/projects/opencvlibrary/cmake版本是3.5.0-rc2,mingw版本是4.9.3,opencv版本是2.4 0.13.我在我的mingw上安装了haskell和allegro5库的ghc.

下载后,我在C:/ opencv中提取它.使用cmake-gui我将源文件夹设置为C:/ opencv/sources,将build设置为C:/ opencv/build.关于配置标志,我只是取消标记BUILD_opencv_pyhon,因为我没有安装python.这是配置和生成步骤的日志:

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
Run Code Online (Sandbox Code Playgroud)

我已经尝试过其他版本的opencv,最新版本的2.4.7,等等.每次我只是构建它并在尝试执行编译程序后得到相同的错误.我试图指定编译器(我安装了mingw的其他版本),gcc C:\ mingw\bin\gcc.exe和g ++ C:\ mingw\bin\g ++.exe.没有运气,同样的错误.我尝试安装新版本的mingw,并将其放在C:\ mingwnew中,我指定编译器,对于gcc C:\ mingwnew\bin\gcc.exe和g ++ C:\ mingwnew\bin\g ++.exe.没运气.

生成后,我只到文件夹c:\ opencv\build并输入C:\ mingw\bin\mingw32-make.exe(或另一个尝试中的C:\ mingwnew\bin\mingw32-make.exe).关于opencv代码本身有一些警告(我尝试了一些不同的版本).之后,它最终没有任何错误.我键入,C:\ mingw\bin\mingw32-make.exe安装.之后,我有一个新文件夹C:\ opencv\build\install\x86\mingw.在C:\ opencv\build\install\x86\mingw\bin中有一些示例,尝试执行它们.同样的错误.

我之后尝试的事情:

  • 将C:\ opencv\build\install\x86\mingw文件夹复制到我的mingw.将libs和dll复制到我的项目文件夹目录(路径中没有空格),将dll复制到system32文件夹.并试图用-Wall编译,没有错误,但是当尝试执行时,同样的错误.

  • 编译

    c:/ mingw/bin/g ++.exe -Wall -I"C:/ opencv/build/install/include"loadimg.cpp libopencv_core2413.dll.a libopencv_highgui2413.dll.a -o loadimg,尝试静态编译.

  • 编译

    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

  • 尝试依赖Walker,但在新SO(Windows 10)中使用它时只会遇到一些错误,我在另一个线程中发现它,但它没有给我任何线索.

  • 试过旧版opencv的预编译二进制文件.同样的错误.

  • 尝试了mingw64,我甚至无法编译一个hello世界.好像它已经充满了bug.但我认为mingw32不是问题,因为我之前用mingw32(allegro5)以相同的方式编译了其他库,并且它有效.

我搜索了很多,并尝试了很多东西,包括尝试opencv docs提供的其他示例代码.我无法安装linux,或者用户另一台计算机,所以这是我唯一的一个选项,并且在构建opencv十几次之后,两周之后,我就无法自己解决错误了.

是否需要任何线索或更多信息?提前致谢.

Ari*_*cia 7

对我来说,在OpenCVPackaging.cmake中添加OPENCV_VCSVERSION = 2.4.13(使用OpenCV版本2.4.13):

#in OpenCVPackaging.cmake file (line 23)
set(OPENCV_VCSVERSION "2.4.13") #<--add
set(CPACK_PACKAGE_VERSION "${OPENCV_VCSVERSION}")
Run Code Online (Sandbox Code Playgroud)