views:

1225

answers:

3

Can someone link me a good guide for using libraries in a c or c++ project?

Right now I'm trying to add OpenCV to a newly created project. I've added all the directories I can think of in "Project and Solutions -> VC++ Directories" and to make sure I've dragged and dropped all the .lib and .dll files into the project.

The project builds but when I run the simple "Hello, World program" it gives me this error message:

"cv.exe unable to locate component.

This application has failed to start because cv200.dll was not found. Re-installing the application may fix this problem."

How can I really add this cv200.dll? I've dragged&dropped it into the project.. Thanks!

+1  A: 

You need to make sure that cv200.dll is in the DLL search path at run time. The easiest way to do this is to put it in the same directory as the built executable. Dragging and dropping a DLL or LIB file into your project has no effect.

MSDN has a good description of the full DLL search order when loading libraries at runtime.

Nick Meyer
I'd also suggest adding a post-build step to copy the dll to the build directory, as that will ensure that it gets set up correctly the first time you build.
the_mandrill
Thanks Nick!The_mandrill, how do I do that?
Dimitar
Better to reference it explicitly from a separate folder in you version control tree and have the application pull it into the bin directory on build.
Murph
A: 

By default during installation OpenCV create env. variable path \bin. All dll assumed to be in that dir. However you are using OpenCV 2.0, and OpenCV 2.0 installation doesn't include lib and dll files for Visual Studio. You seems already built all dll's and lib's. If you installed OpenCV correctly just move all dll's into \bin (for example C:\Program Files\OpenCV\bin) If for some reason you are missing some dll or libs here is instruction how to build them http://mirror2image.wordpress.com/2009/10/20/switching-to-opencv-2-0-with-vs2005/

mirror2image
A: 

je veux installer OpenCV 2.0 en visual studio sous windows donc je suivre toutes les étapes. mais il ya une erreur : Build started: Project: essai, Configuration: Debug Win32 ------ Linking... LINK : fatal error LNK1104: cannot open file 'cv.lib' Build log was saved at "file://c:\Documents and Settings\tarak\Mes documents\Visual Studio 2008\Projects\essai\essai\Debug\BuildLog.htm" essai - 1 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== veuillez vous me donner une solution.

mouna