1

The issue is that OpenCV has not been setup properly to run a simple "Hello World" type of program.

Running: Windows 8, 64 bit

IDE: CodeBlocks 13.12

OpenCV: 2.4.10

Actions Taken


  • Downloaded OpenCV
  • Binaries were built with CMake (followed basics steps of this tutorial: http://kevinhughes.ca/tutorials/opencv-install-on-windows-with-codeblocks-and-mingw/)
  • Set PATH for Environment Variables to C:\opencv\build\x64\mingw\bin;C:\MinGW\bin
  • Set Link libraries to all contained in C:\opencv\build\x64\mingw\lib
    * Note * The files' type was .dll.a not .dll
  • Set Search directories Compiler to C:\opencv\build\include
  • Set Search directories Linker to C:\opencv\build\x86\mingw\lib
  • Copied code from OpenCV tutorial to test proper configuration

'

   #include <opencv2/core/core.hpp>
   #include <opencv2/highgui/highgui.hpp>

    using namespace cv;

    int main()
   {
    Mat image;// new blank image
    image = cv::imread("test.png", 0);// read the file
    namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// create a window for display.
    imshow( "Display window", image );// show our image inside it.
    waitKey(0);// wait for a keystroke in the window
    return 0; 
    }'
  • Built and Ran
  • Got the following System Error

The program can't start because libopencv_core2410.dll is missing from your computer. Try reinstalling the program to fix this problem.

What could be wrong with the configuration?

Zephyr
  • 27
  • 1
  • 5
  • Copy the DLLs to the directory where your exe is. – sashoalm Dec 22 '14 at 18:25
  • Find where in the directory with MinGW the «libopencv_core2410.dll» file, and either add the path to $PATH, either add in the project to link paths. – Hi-Angel Dec 22 '14 at 18:28
  • @sashoalm, terrible idea. totally defeats "shared libs" – berak Dec 22 '14 at 18:29
  • @berak Well, that's kind of the way on Windows. You really think anyone will just hope the DLL happens to be on the client's machine? Every program just places the DLLs in the exe's directory, go look in `C:\Program Files`. This is not UNIX. – sashoalm Dec 22 '14 at 22:00

2 Answers2

2

The configuration of Code::Blocks is okay since you managed to build and run.

The DLL directory needs to be in the PATH, or else the DLL needs to be in the same directory as the executable.

You can just copy it there, but I'd add it to the PATH variable.

Command sysdm.cpl to run the System applet. In Advanced tab press button "Environment variables..." at bottom. Add or edit PATH in user environment defaults.

Restart Code::Blocks.

Cheers and hth. - Alf
  • 142,714
  • 15
  • 209
  • 331
  • The DLL ("C:\opencv\build\x86\mingw\bin\libopencv_core2410.dll") was added to the PATH variable and Code::Blocks restarted. However, the same system error appeared again. Is the DLL being added to the PATH incorrectly? – Zephyr Dec 22 '14 at 18:40
  • No, don't add the DLL file itself. Add the directory where it is. But it appears you already have that. That's perplexing. The message you get is from the Windows loader. Check that you really have that file, `libopencv_core2410.dll`. – Cheers and hth. - Alf Dec 22 '14 at 18:44
  • Yes, the file exists and is in C:\opencv\build\x86\mingw\bin. Should I move it to the executable's directory? – Zephyr Dec 22 '14 at 18:54
  • @Zephyr: Yes I would try that (copying, not moving). But in the long run you need to find out what's really going on here. With the containing directory in the PATH it should have been found. Note, if not clear, that changing the PATH default value does not change the value of PATH in any given process, such as a command interpreter instance. That's why I wrote "restart Code::Blocks", but also, if you're running the program from a command interpreter, restart that. – Cheers and hth. - Alf Dec 22 '14 at 18:56
  • Thanks, copying over ALL of the DLLs from C:opencv\build\x86\mingw\bin eliminated the system error. However, another error (possibly unrelated) is occurring: Entry Point Not Found in libopencv_core2410.dll – Zephyr Dec 22 '14 at 19:10
  • Surely it's reporting which function it's not finding. – Cheers and hth. - Alf Dec 22 '14 at 19:12
  • It did not state a specific function: "The procedure entry point_gxx_personality_v0 could not be located in the dynamic link library C:\Users\UserName\Desktop\OpenCVTest\Debug\libopencv_core2410.dll – Zephyr Dec 22 '14 at 19:25
  • Yes, that's a function name. [Another SO answer](http://stackoverflow.com/questions/329059/what-is-gxx-personality-v0-for) indicates that maybe you're linking with `gcc` command, but should be using `g++`. – Cheers and hth. - Alf Dec 22 '14 at 20:10
0

Simply you should set the DLL file in the path variable like C:\opencv\my_build\install\x64\mingw\lib\libopencv_core2411.dll.a here my_build is a directory in which i make all library as you write in post.

Chandan Sharma
  • 2,803
  • 1
  • 17
  • 25