Ask Your Question
0

Cross compiling opencv using eclipse for pi

asked 2013-09-13 02:40:14 -0600

LAKSHMI gravatar image

updated 2013-09-17 01:51:29 -0600

Hi, I used opencv for eclipse and it is running fine. I tried the display image program from the site and it is working fine (other programs too). But when I try to cross compile the same for pi, I am having difficulty to add the opencv libraries. the cross compile path and the opencv library paths are different. How do I correct this.

Error looks like this:

Building target: displayimagerpi
Invoking: Cross G++ Linker
arm-linux-gnueabihf-g++ -L/usr/local/include/opencv2 -L/usr/local/include/opencv -o "displayimagerpi"  ./test.o   -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d  -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann
/home/../rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.7.2/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lopencv_core
/home/../rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.7.2/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lopencv_imgproc
/home/../rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.7.2/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lopencv_highgui
/home/../rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.7.2/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lopencv_ml
/home/../rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.7.2/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lopencv_video
/home/../rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.7.2/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lopencv_features2d
/home/../rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.7.2/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lopencv_calib3d
/home/../rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.7.2/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lopencv_objdetect
/home/../rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.7.2/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lopencv_contrib
/home/../rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.7.2/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lopencv_legacy
/home/../rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.7.2/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lopencv_flann
collect2: error: ld returned 1 exit status

Iam not able to resolve this

Thanks in advance

edit retag flag offensive close merge delete

Comments

1

no idea about cross-compiling, pi or eclipse, but:

-L/usr/local/include/opencv2

is most probably wrong.

did you mean -I here(the include path) ? -L should point to the dir where your libs are, not to the include files.

berak gravatar imageberak ( 2013-09-17 01:57:32 -0600 )edit

Yes.. I think so but my /usr/local/lib gives me error. i tried looking for the libs and added this path. it works fine for all the programs but cross compiling.

to get the lib path I tried the command

pkg-config --libs opencv and it does not give me -l path!!!!!

instead i got

/usr/local/lib/libopencv_calib3d.so .. all with .so extension.

when i had to get -L and -l paths. so i added this path and it works (but for crosscompiling).

I am running out of ideas how to resolve this.

LAKSHMI gravatar imageLAKSHMI ( 2013-09-17 05:09:34 -0600 )edit
2

Hi Berak I kind of figured out the error. when i replayed to u ..i saw the lib path . I added the same to the lib path and voila it works... But the executable i got is weird.. all i have to see now is if my Pi accepts it or not ! Thats the next mission

Thanks for pointing out the error. I could figure out the error :-) Thank u

LAKSHMI gravatar imageLAKSHMI ( 2013-09-17 06:46:19 -0600 )edit

Just a general observation: it's always simpler to build your program locally than setting up a cross-compile chain. Copy the source to the Raspberry Pi and run make. It's much simpler, even if the compilation is a bit slower (at least you won't lose time with the cross-compile chain).

kbarni gravatar imagekbarni ( 2019-03-11 12:13:35 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-09-17 01:53:30 -0600

I guess you are talking about the Raspberry Pi board when mentioning you want to compile and get openCV running on Pi. I suggest following this 7 step tutorial which is nice and clean and explains you in details how to do it.

edit flag offensive delete link more

Comments

No I am yet to install OpenCV on Raspberry pi. Iam planning to do that later.

Iam trying to creat a binary file for raspberry Pi using eclipse.I have installed OpenCV and Eclipse in KUbuntu. hence my Cross compiler path is set to gcc-linaro-arm-linux-gnueabihf-raspbian. so when i try to include OpenCv libraries which are in root , linker is trying to locate the lib files in the gcc folder and giving me error. So iam not able to figure out how to specify the path for both the libs! Hope iam able to convey the my problem!

LAKSHMI gravatar imageLAKSHMI ( 2013-09-17 04:59:39 -0600 )edit
1

But why should you cross compile it? The tutorial I mentioned does a compilation of OpenCV also. Can't you at least try it out?

StevenPuttemans gravatar imageStevenPuttemans ( 2013-09-17 05:54:07 -0600 )edit
1

Yes thats the plan. But my Pi is not always on. And it takes longer to compile on pi. so Iam trying out the alternative. Thank u so much.. I just now figured out the error and compiled the program. but the executable i got looks wired :-P one thing at a time . I'll try this on Pi. Hopefully this should work!!! Tomorrow I'll install OpenCv on Pi. my SD card is 4GB OpenCv will take up all the space. hence trying to figure out other ways! but Thank you so much

LAKSHMI gravatar imageLAKSHMI ( 2013-09-17 06:34:22 -0600 )edit
1

LAKSHMI, you mention that you figured it out, can you share the answer; have the same problem and can't figure it out :(

vyga gravatar imagevyga ( 2013-11-14 15:52:24 -0600 )edit
1

Sorry for the delay.. I failed to cross compile. Creating a binary file for OpenCV libraries using eclipse is not working for me. even tough everything works fine, and I try to link the binary file to the Pi, It fails. So I gave up.But I could easily install opencv on Raspberry Pi and compile the program using gcc or cmakeTest file. That is much simpler and easier. @StevenPuttemans also suggested the same.

LAKSHMI gravatar imageLAKSHMI ( 2014-01-31 01:11:52 -0600 )edit

Then please mark this thread as solved if you have a solution that works for you.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-01-31 01:55:58 -0600 )edit

Its not exactly solved.. I found an alternative would be correct. May be there is a solution to this.

LAKSHMI gravatar imageLAKSHMI ( 2014-01-31 03:38:06 -0600 )edit

Hey! i need the same things. need to compile my c++ opencv program on eclipse on pi2. and i was suggested to work on some cross complier. because pi2 is too slow for the job i need. Can anyone help me out? any other ways other than cross compilation?

durritoz gravatar imagedurritoz ( 2016-09-04 11:40:18 -0600 )edit

Why would the pi be too slow. It will simply take 2-3 hours to compile, but when setup you can let it run overnight.

StevenPuttemans gravatar imageStevenPuttemans ( 2016-09-05 03:03:05 -0600 )edit

Question Tools

Stats

Asked: 2013-09-13 02:40:14 -0600

Seen: 3,113 times

Last updated: Sep 17 '13