简体   繁体   中英

Error on building project using opencv

I have installed visual studio 2013.

I downloaded 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 .

I have 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.

I researched this error and found that it has something to do dlls but didn't found a proper solution.

First of all, try as far as possible to build the sources yourself using 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. 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:

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)

  • Check on the path of the .dll files that your program needs during runtime; 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. 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.

  • 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. try, to create an empty c++ console application, this should give you a declaration of the main function as main not _tmain. http://msdn.microsoft.com/en-us/library/h9x39eaw%28v=vs.71%29.aspx

  • Check if you build with 'precompiled headers' if you are, then disable them.

Wish you luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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