Reputation: 132
I've recently installed OpenCV( with cmake) and when I try to run for example build_all.sh from sample/c I get the following errors:
compiling fback_c.c
gcc: error: rt: No such file or directory
gcc: error: pthread: No such file or directory
gcc: error: m: No such file or directory
gcc: error: dl: No such file or directory
......................................
compiling find_obj_calonder.cpp
g++: error: rt: No such file or directory
g++: error: pthread: No such file or directory
g++: error: m: No such file or directory
g++: error: dl: No such file or directory
Note: There are more of them but all of them are the same for every file.
But when I use this on a sample from sample/cpp the program actually compile:
g++ test.cpp -o test -I/usr/local/include/opencv -I/usr/local/include -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann
Also when I try to compile a .py file I get the following error
ImportError: No module named cv2
I'm using x64 Fedora 19.
I would like to know why when I use that command the program compiles but when I use the default method it does not work. Also what should I do in order to compile a .py ?
Upvotes: 0
Views: 626
Reputation: 429
I'm not intimately familiar with Fedora Core (it was still just RedHat when I was using it), but many modern Linux distributions put normal system libraries in /usr/lib and includes in /usr/include. Since you compiled OpenCV from scratch it put it in /usr/local/... and the build system and python aren't told to look there by default.
This is why your manual gcc command worked (the -I and -L switches tell gcc to look in /usr/local/...)
Installing the packages that you did simply installed the distribution version into /usr/..., so while it works, you actually have 2 different versions on your system and the samples and python are using the version installed in /usr/... (from the package manager) not your custom install.
You could have an entire discussion around compiling yourself vs. using the package manager, but for now, if you do decide to compile things yourself make sure to set the prefix to /usr instead of /usr/local OR setup your system to look in /usr/local as well as /usr.
Upvotes: 0
Reputation: 132
Ok, so I tried again and this time I've installed the following packages from Software Install
Development Files for Using the OpenCv Library
Python biding for apps
. In their official instruction they have no stated this. Now it compiles without errors.
Upvotes: 0