Mariusmssj4
Posts: 15
Joined: Thu Jan 23, 2014 10:37 am

OpenCv C++

Thu Jan 23, 2014 10:56 am

Hey guys,

I am working on a project of porting my OpenCV code from Windows to raspberry pi but I am having hard time finding a way to get OpenCV C++ working. I've found many guides but they seemed to only have libraries and code support for only C.

The only promising one I found was this: RaspiCam: C++ API for using Raspberry camera with/without OpenCv

Which I got it installed but once I try to compile the simpletest_raspicam_cv.cpp using

Code: Select all

 g++ simpletest_raspicam_cv.cpp -o  simpletest_raspicam_cv -I/usr/local/include/ -lraspicam -lraspicam_cv -lmmal -lmmal_core -lmmal_util -lopencv_core -lopencv_highgui 

I get this:

Code: Select all

/usr/bin/Id: cannot find =lmmal
/usr/bin/Id: cannot find =lmmal_core
/usr/bin/Id: cannot find =lmmal_util
anyone know how could I make OpenCv C++ project work in pi?

I am using Raspbian.

Thank you

User avatar
topguy
Posts: 6491
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: OpenCv C++

Thu Jan 23, 2014 2:15 pm

You are only missing to tell the linker that the missing libraries is located in "/opt/vc/lib/". In the guide you linked to he uses full path to those libs but I guess you should only need to add:

Code: Select all

-L/opt/vc/lib

Mariusmssj4
Posts: 15
Joined: Thu Jan 23, 2014 10:37 am

Re: OpenCv C++

Thu Jan 23, 2014 3:29 pm

topguy wrote:You are only missing to tell the linker that the missing libraries is located in "/opt/vc/lib/". In the guide you linked to he uses full path to those libs but I guess you should only need to add:

Code: Select all

-L/opt/vc/lib
Why thank you that worked right away :)

now just running the application fails.

Code: Select all

./simpletest_raspicam_cv

Code: Select all

./simpletest_raspicam_cv: error while loading shared libraries: libraspicam.so.0.0: cannot open shared object file: No such file and directory

User avatar
topguy
Posts: 6491
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: OpenCv C++

Thu Jan 23, 2014 4:46 pm

raspicam.so is the library you compiled earlier in the guide and hopefully installed with "sudo make install".

Did you notice where it installed that file ? (I'm guessing it was "/usr/local/lib", but you should check.)

You may need to tell your RasPi that there are some new libraries in that directory.

Code: Select all

sudo cat /etc/ld.so.conf.d/*
This command lists all paths where the Pi will look for .so files, you shoud verify that the directory where raspicam.so was installed is in that list.

If it isnt in that list you can add it temporarely by doing:

Code: Select all

export LD_LIBRARY_PATH="/usr/local/lib"
before starting the application.

You can also check which libraries a program need and where they are located with the "ldd" command.

Mariusmssj4
Posts: 15
Joined: Thu Jan 23, 2014 10:37 am

Re: OpenCv C++

Fri Jan 24, 2014 4:18 pm

Thank you topguy it worked brilliantly :)

elcocui
Posts: 1
Joined: Fri May 08, 2015 3:51 pm

Re: OpenCv C++

Fri May 08, 2015 3:54 pm

Hi, how do i add/modify -L/opt/vc/lib to get g++ working? r do I need to modify it elsewhere? sorry for asking.. Im new to this field.

User avatar
topguy
Posts: 6491
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: OpenCv C++

Mon May 11, 2015 1:34 pm

You need to be more specific, you have just hijacked an old thread but please explain the problem like you were making a new one.

- What are you trying to do ?
- What happens ? ( with exact error output )

Return to “C/C++”