Ask Your Question
0

Installation of OpenCV in a local directory in Ubuntu 16.04

asked 2017-03-27 07:41:24 -0600

missionary gravatar image

updated 2017-03-27 11:10:55 -0600

I have successfully installed OpenCV 2.4.13 in a local directory in my system. But, I am unable to run a sample code and it is giving the error -

g++ -L/home/zeus/Libraries/opencv-2.4.13/release/install/lib -I/home/zeus/Libraries/opencv-2.4.13/release/install/include test.cpp -o test /tmp/ccUdWpdH.o: In function main': test.cpp:(.text+0xb9): undefined reference tocv::imread(std::__cxx11::basic_string<char, std::char_traits<char="">, std::allocator<char> > const&, int)' test.cpp:(.text+0xe1): undefined reference to cv::waitKey(int)' test.cpp:(.text+0x101): undefined reference tocv::_InputArray::_InputArray(cv::Mat const&)' test.cpp:(.text+0x144): undefined reference to cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)' /tmp/ccUdWpdH.o: In functioncv::Mat::~Mat()': test.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference to cv::fastFree(void*)' /tmp/ccUdWpdH.o: In functioncv::Mat::release()': test.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x47): undefined reference to `cv::Mat::deallocate()' collect2: error: ld returned 1 exit status Makefile:9: recipe for target 'test' failed make: * [test] Error 1

My OpenCV is installed in /home/zeus/Libraries/opencv-2.4.13/release/install/

PS - I want to install it locally for some reasons. Please don't tell me to install it in /usr/lib/ as I don't want to do it that way.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-03-27 07:57:06 -0600

berak gravatar image

if that is your complete cmdline above, then you simply forgot to link nessecary opencv libs:

g++ -L/home/zeus/Libraries/opencv-2.4.13/release/install/lib -I/home/zeus/Libraries/opencv-2.4.13/release/install/include test.cpp -o test /tmp/ccUdWpdH.o -lopencv_core -lopencv_highgui -lopencv_imgproc
edit flag offensive delete link more

Comments

This resolved my make problem. But, while running the executable I am getting the following error - ./run: error while loading shared libraries: libopencv_highgui.so.2.4: cannot open shared object file: No such file or directory

missionary gravatar imagemissionary ( 2017-03-27 11:10:22 -0600 )edit

oh, forgot to mention: you have to run ldconfig in your custom dir, so the so's can be found at runtime

berak gravatar imageberak ( 2017-03-27 11:13:43 -0600 )edit
1

Thank you very much for your help! I have finally got it working. I created a file named opencv.conf in /etc/ld.so.conf.d/, then added the path of the local directory where I had installed the libraries and then I ran sudo ldconfig -v to link the shared library search path.

missionary gravatar imagemissionary ( 2017-03-28 02:21:00 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-03-27 07:40:45 -0600

Seen: 379 times

Last updated: Mar 27 '17