开发者

Why can't my c++ program find the necessary .dll file?

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, 开发者_JS百科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.)


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!


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.


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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜