I have been trying to run some sample c programs that uses the cv.h library, but what happened was that the compile complains the file could not be found. So I am guessing I need to some how set the compiler's path. How do I do that?
            Asked
            
        
        
            Active
            
        
            Viewed 1,758 times
        
    2 Answers
2
            On linux, I use pkg-config to assist me on that task:
g++ program.cpp -o program `pkg-config --cflags --libs opencv`
        karlphillip
        
- 92,053
 - 36
 - 243
 - 426
 
- 
                    You know the compiler complains about .h files for opencv2 as well. How come I don't find opencv2 in the /user/include/.. path? Is it because I didn't install the full version? – Mark Oct 15 '11 at 20:28
 - 
                    There a couple of things that could be causing this: an install problem, or a bad source code. Either way, I suggest you check http://opencv.willowgarage.com/wiki/InstallGuide_Linux or the guide for Ubuntu, http://opencv.willowgarage.com/wiki/InstallGuide%20%3A%20Debian. And most importantly, please first use a source code that you know it works (like this one, http://stackoverflow.com/questions/7011238/opencv-2-3-c-visual-studio-2010/7014918#7014918) to test your environment, and after that you are free to go on and write your own programs. – karlphillip Oct 15 '11 at 20:36
 
0
            
            
        With gcc, you need to add -I/path/to/the/folder/where/cv.h/is/. You'll probably also need the -L/path/to/the/folder/where/libopencv.so/is -lopencv.
        Marc Plano-Lesay
        
- 6,808
 - 10
 - 44
 - 75
 
- 
                    I discovered that the necessary includes are in /usr/include/opencv. Shouldn't the compiler search in the place already? – Mark Oct 15 '11 at 08:40
 - 
                    1With `#include
`, it'll probably find it. Else, if you use `#include – Marc Plano-Lesay Oct 15 '11 at 08:42`, you'll need to add `-I/usr/include/opencv`.