Cross compiling opencv using eclipse for pi
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
no idea about cross-compiling, pi or eclipse, but:
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.
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.
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
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).