4

I am trying to use OpenCV (a computer vision library), which appearently uses a few .dll files, located in C:\OpenCV\bin (which has been added to the system PATH variable). However, if I try to run a simple test program, it gives a system error:

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

If I copy the highgui.dll file into the system32 folder, it works, but I don't want to have to put all the necessary .dll files in the system32 folder.

Does anyone know why the .dll file can't be found or what I should do to fix it?
(I already checked all paths in the PATH variable for validity.)

Linus Caldwell
  • 10,908
  • 12
  • 46
  • 58
GroovyPanda
  • 3,694
  • 8
  • 31
  • 42
  • semi-related question: http://stackoverflow.com/questions/2637499/how-can-a-win32-app-plugin-load-its-dll-in-its-own-directory/ – sean e Apr 15 '10 at 22:45
  • 2
    Welcome to DLL hell. Not only do you have to figure out where the DLL is, but you will have to find out which one is the *correct* version to use. This is the reason that many applications place the DLLs in the same directory as the executable. I suggest you use explicit paths for your DLLs, rather than relying on a system path (which could lead to a DLL that is an incorrect version). – Thomas Matthews Apr 16 '10 at 00:24
  • I don't think I can edit the paths to the DLLs, as they are probably specified within the OpenCV library. – GroovyPanda Apr 16 '10 at 07:07

5 Answers5

1

I tracked down the executable that was built by Netbeans before running and launched it, and it gave no errors (so Netbeans probably uses its own paths for executing), so tried to find out how I could make Netbeans search the right paths for the DLLs, and after adding an environment variable PATH=C:/OpenCV2.1/bin (Project Properties > Run > Environment), the program ran correctly!
I do hope this is not some sort of hack that 'acdidentally' solves my problem while creating worse side-effects...
Thanks for the help!

GroovyPanda
  • 3,694
  • 8
  • 31
  • 42
  • I know I'm commenting on an old post, but I feel this is not a good answer. I believe it would be better to copy the DLL to the executable's directory rather than relying on modifying the environment. The more programs that pollute PATH the worse things get... – Phlucious Aug 21 '13 at 21:41
0

Have you tried copying highgui.dll into your build folder. As it is dynamically linked your program will look locally to find it and if it is not being copied into your build directory it won't be able to find it.

Chris
  • 26,744
  • 48
  • 193
  • 345
  • I'm using Netbeans, but I don't see a build folder in the project (sorry, I'm not quite familiar with builds etc). However, isn't it strange that the way OpenCV is installed (with a Windows Installer), it does not work yet? Would it still require moving files to different locations? – GroovyPanda Apr 16 '10 at 07:14
0

How is the program being launched and how is the PATH variable being updated?

If you update the path in a command window, but launch the app from your IDE or from the Windows desktop, the environment for the launched process will probably have a different PATH setting than the environment for your command window.

Similarly if you change the PATH in the System Control Panel applet, it might not have an effect on an IDE or command window that was launched before you made the PATH edit.

Michael Burr
  • 333,147
  • 50
  • 533
  • 760
  • The bin directory of OpenCV was added during installation of OpenCV. Then I wrote a simple program in Netbeans and launched it. So the PATH variable is set before launch. – GroovyPanda Apr 16 '10 at 07:06
  • Just to be clear - was Netbeans launched after OpenCV was installed? – Michael Burr Apr 16 '10 at 14:09
0

I had this problem using Visual Studio 12 and after checking to make sure I had no typos in my PATH for the tenth time, I noticed there was a space after the semi-colon from the previous path. I removed it and Visual Studio was able to find the DLLs I needed.

If you have multiple paths stored in your PATH variable, make sure they are separated by semi-colons with no spaces.

knr7201
  • 89
  • 4
0

I am using OpenCV 2.2 with Visual Studio 10. to create a new project i do the following steps... 1.VC++ Directories -> Include Directories -> C:\OpenCV2.2\include Library Directories -> C:\OpenCV2.2\lib 2.C/C++ -> General -> Additional Include Directories ->C:\OpenCV2.2\bin 3.Linker -> Input -> opencv_core220.lib;opencv_highgui220.lib;opencv_calib3d220.lib;opencv_contrib220.lib;opencv_features2d220.lib;opencv_ffmpeg220.lib;opencv_flann220.lib;opencv_gpu220.lib;opencv_imgproc220.lib;opencv_legacy220.lib;opencv_ml220.lib;opencv_objdetect220.lib;opencv_ts220.lib;opencv_video220.lib;

  1. i copy all the dll files to the project debug folder. it gives me no hitch and everything is fine..
Sayak
  • 339
  • 1
  • 6
  • 19