简体   繁体   English

使用OpenCV构建项目时出错

[英]Error on building project using opencv

I have installed visual studio 2013. 我已经安装了Visual Studio 2013。

I downloaded opencv 2.4.6.0. 我下载了opencv 2.4.6.0。

I used this tutorial to install opencv on windows and configure VS : http://opencv-srf.blogspot.ro/2013/05/installing-configuring-opencv-with-vs.html . 我使用本教程在Windows上安装opencv并配置VS: http : //opencv-srf.blogspot.ro/2013/05/installing-configuring-opencv-with-vs.html

I have windows 7 ultimate SP1 x64. 我有Windows 7 Ultimate SP1 x64。

All well until now . 到现在为止一切都很好。

I copy-paste this in the project http://opencv-srf.blogspot.ro/2013/06/load-display-image.html and CTR-F5 the project and got the following error : The application was unable to start correctly (0xc0000007b).Click ok to close the application. 我将其复制粘贴到项目http://opencv-srf.blogspot.ro/2013/06/load-display-image.html和CTR-F5项目中,并收到以下错误: 应用程序无法正确启动(0xc0000007b)。单击“确定”关闭该应用程序。

I researched this error and found that it has something to do dlls but didn't found a proper solution. 我研究了此错误,发现它与dll有关,但是找不到合适的解决方案。

First of all, try as far as possible to build the sources yourself using CMAKE+VS. 首先,尽可能尝试使用CMAKE + VS自己构建源。 It makes sure that ONLY the binaries that are required by your system are generated and nothing else.. You can use the official guide as reference for this (note that a lot of things they ask to install are optional; download and install only those that you need).. 它可以确保生成系统所需的二进制文件,而别无其他。.您可以使用官方指南作为参考(请注意,他们要求安装的许多东西都是可选的;仅下载并安装那些你需要)..

Next, use CMake to link libraries and include directories for your own project. 接下来,使用CMake链接库并包含您自己项目的目录。 It makes your life easier and also for anyone else who will be extending/reading your code in the future. 它使您的生活变得更轻松,也使将来将要扩展/阅读您的代码的其他任何人。 For example, to link OpenCV, add the follow lines of code to your project's CMAKE file: 例如,要链接OpenCV,请将以下代码行添加到项目的CMAKE文件中:

FIND_PACKAGE( OpenCV REQUIRED )
TARGET_LINK_LIBRARIES( myProject ${OpenCV_LIBS} )

Hope this helps. 希望这可以帮助。

Please confirm on this quick thoughts of mine if you like: 如果您愿意,请确认我的快速想法:

  • You said that you have 'x64' architecture and the OpenCV tutorial you provided uses x86 .lib files to build your program(I think if this was the case the program won't even build, but you won't get hurt if you see if you uses the same x86 .lib files to build with as in the tutorial) 您说您拥有'x64'架构,并且您提供的OpenCV教程使用x86 .lib文件来构建程序(我想如果是这样的话,该程序甚至无法构建,但是如果看到的话不会受到伤害如果您使用与教程中相同的x86 .lib文件进行构建)

  • Check on the path of the .dll files that your program needs during runtime; 检查程序在运行时所需的.dll文件的路径; see if you made a mistake in the configuration of the PATH environment variable (it is really error prone), also, check that the path of the .dll you put in the PATH variable are the x64 ones not the x86 one. 请查看您是否在PATH环境变量的配置中犯了错误(这确实容易出错),还要检查放入PATH变量中的.dll的路径是否是x64而不是x86。 also, you can put all the .dll files your program needs in the program directory in the same folder, it is the direct way of not using the PATH environment, Windows looks first at the .dll files in the same directory of the program needing them. 同样,您也可以将程序需要的所有.dll文件放在同一文件夹中的程序目录中,这是不使用PATH环境的直接方法,Windows首先查看程序需要的同一目录中的.dll文件他们。

  • I noticed that the main function in the tutorial is not simple main it is _tmain, which as I remember means that you use an windows api to create a win32 application. 我注意到本教程中的主要功能不是简单的main,而是_tmain,我记得这意味着您使用Windows api创建了一个win32应用程序。 try, to create an empty c++ console application, this should give you a declaration of the main function as main not _tmain. 尝试创建一个空的c ++控制台应用程序,这应该使您将main函数声明为main而不是_tmain。 http://msdn.microsoft.com/en-us/library/h9x39eaw%28v=vs.71%29.aspx http://msdn.microsoft.com/zh-cn/library/h9x39eaw%28v=vs.71%29.aspx

  • Check if you build with 'precompiled headers' if you are, then disable them. 检查是否使用“预编译头”进行编译,然后禁用它们。

Wish you luck. 祝您好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM