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

时间:2016-07-19 14:13:56

标签: c++ opencv 64-bit 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;
}

好吧,最初我是从源代码构建的,在sourceforge链接下载https://sourceforge.net/projects/opencvlibrary/ cmake版本是3.5.0-rc2,mingw版本是4.9.3,opencv版本是2.4.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

我已经尝试过其他版本的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的/建造/安装/ 86 / 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十几次之后,两周之后,我就无法自己解决错误。

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

5 个答案:

答案 0 :(得分:6)

对我来说,在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}")

答案 1 :(得分:2)

错误在此行中:OpenCV 2.4.13的常规配置

我今天遇到这个错误,因为有3.1.0版本,但是 http://opencv.org/为您提供版本2.4.13作为其链接的不匹配。

所以我安装了here的最新版本,之后我没有更多错误(如下所示)。

cmake / OpenCVPackaging.cmake上的CMake警告:23(消息):   CPACK_PACKAGE_VERSION与version.hpp提供的版本不匹配   头球攻门! 呼叫堆栈(最近一次呼叫):   CMakeLists.txt:1105(包括)

抱歉英语不好......

答案 2 :(得分:1)

我遇到了和你一样的问题。我把 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <h1>Cats Sleep Anywhere</h1> <p> Cats sleep anywhere, any table, any chair.<br> Top of piano, window-ledge, in the middle, on the edge.<br> Open draw, empty shoe, anybody's lap will do.<br> Fitted in a cardboard box, in the cupboard with your frocks.<br> Anywhere! They don't care! Cats sleep anywhere.<br> <br> <img id="cat-picture"> <b>Eleanor Farjeon</b></p> <p></p> </body> </html>import turtle def drawPolygon(t, sideLength, numSides): t.goto(0, 0) turnAngle = 360 / numSides for i in range(numSides): t.forward(sideLength) t.right(turnAngle) def drawCircle(anyTurtle, radius): circumference = 2 * 3.1415 * radius sideLength = circumference / 360 drawPolygon(anyTurtle, sideLength, 360) def drawFilledCircle(anyTurtle, radius, color): anyTurtle.fillcolor(color) anyTurtle.begin_fill() drawCircle(anyTurtle, radius) anyTurtle.end_fill() anyTurtle.hideturtle() wn = turtle.Screen() wheel = turtle.Turtle() drawFilledCircle(wheel, 80, "pink") wn.exitonclick() 放到项目目录下,成功了。
解决方案来自here
实际上,我仍然不明白它为什么有效。 libstdc++-6.dll 中可能会出错。

答案 3 :(得分:0)

OpenCV论坛上的回答是you cannot build the opencv_contrib modules with 2.4

建议你改为master branch from github。这就是我做的。 (无论如何,the sourceforge link遇到了麻烦。)

之后我没有发现CPACK_PACKAGE_VERSION does not match错误。

答案 4 :(得分:0)

如前所述,当我们下载代码而不是使用git进行克隆时会发生这种情况。最简单的方法是在编译之前遵循opencv documentation并检查所需的版本。