Opencv c++ linker problem ARM

asked 2014-06-09 12:13:34 -0600

Jesus gravatar image

Hi guys I am desperate I am trying to compile an .cpp file which use opencv but is imposible for me, Ired many things but I cannot get nothing clear. I do not have experience in this kind of compilation so I am pretty lost. I am working with an ARM, and my code is in c++. I was compiling other files without opencv libraries, and for do that I had to install the toolchain, I got it from the website and I installed it in this Path:

/opt/freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0

after I added this directory to my global PATH like this:

export PATH=$PATH:/opt/freescale/usr/local/gcc-4.4.4-glibc- 2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin export ARCH=arm

after this I set up my enviroment:

export PATH=$PATH:/opt/freescale/usr/local/gcc-4.4.4-glibc- 2.11.1-multilib-1.0 export ARCH=arm export CROSS_COMPILE=arm-linux-

Until here everything is perfect, so I can compile with this command:

arm-linux-g++ IPCamera.cpp -o tru2

and It works perfect, the IPCamera.cpp does not use opencv in this ocasion.

My problem comming now. I followed this tutorial http://www.ridgesolutions.ie/index.php/2013/05/24/building-cross-compiling-opencv-for-linux-arm/ and I finish it propertly. But now I do not have idea how to compile my file, I mean, shall I change the PATH??shall I add the link the libraries or the path libraries, somenthing like this:

arm-linux-g++ -I/path/to/opencv/include -L/path/to/library IPCamera.cpp -o tru2 -lopencv_core -pthread

If it is, How should I do it??. Sorry but I do not have too much idea about that, so someone can help me step by step. Thank you very much

edit retag flag offensive close merge delete

Comments

What compilation/build errors are you getting with that command?

pthbrk gravatar imagepthbrk ( 2014-06-10 00:06:10 -0600 )edit

Hi pthbrk thank you for your answer. The thing is that I have already the toolchain installed /opt/freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0, so I was reading and I find out that I have to download the opencv sources from here "git clone https://github.com/Itseez/opencv.git" and then compile with my toolchain, but I do not know how, shall I change somenthing in the "arm-gnueabi.toolchain.cmake" file for indicate which toolchain compile?? the error message is something like this:

IPCamera.cpp:5:30: error: opencv2/opencv.hpp: No such file or directory IPCamera.cpp:6:39: error: opencv2/highgui/highgui.hpp: No such file or directory IPCamera.cpp:7:39: error: opencv2/imgproc/imgproc.hpp: No such file or directory IPCamera.cpp:11:22: error: X11/Xlib.h: No such file or directory

Jesus gravatar imageJesus ( 2014-06-10 04:25:39 -0600 )edit

IPCamera.cpp:16: error: 'cv' is not a namespace-name IPCamera.cpp:16: error: expected namespace-name before ';' token IPCamera.cpp: In function 'int main(int, char**)': IPCamera.cpp:46: error: 'cv' has not been declared IPCamera.cpp:46: error: expected ';' before 'cap' IPCamera.cpp:52: error: 'Display' was not declared in this scope IPCamera.cpp:52: error: 'disp' was not declared in this scope IPCamera.cpp:52: error: 'XOpenDisplay' was not declared in this scope IPCamera.cpp:53: error: 'Screen' was not declared in this scope IPCamera.cpp:53: error: 'scrn' was not declared in this scope IPCamera.cpp:53: error: 'DefaultScreenOfDisplay' was not declared in this scope IPCamera.cpp:63: error: 'cv' has not been declared IPCamera.cpp:63: error: expected ';' before 'frame'

Jesus gravatar imageJesus ( 2014-06-10 04:25:50 -0600 )edit

It seems that not reconozige the libraries

Jesus gravatar imageJesus ( 2014-06-10 04:26:25 -0600 )edit

If OpenCV build was successful, the opencv installation directory should have a /lib (with libopencv_*.so files) and a /include (with ./opencv2 and ./opencv subdirectories). Do you have them?

pthbrk gravatar imagepthbrk ( 2014-06-10 12:12:12 -0600 )edit

Yes I have it, but how can I make the cross compilation with my toolchain??

Jesus gravatar imageJesus ( 2014-06-11 06:34:41 -0600 )edit

In that case, first try a simple compile, not link, of IPCamera.cpp with this command line:

arm-linux-g++ -H -I/path/to/opencv/include IPCamera.cpp

The -H option is to output all the header files searched by g++. The -I option is to set search directory for header files. Note that it's "I" as in "Image", not an "l" as in "london".

pthbrk gravatar imagepthbrk ( 2014-06-11 07:22:22 -0600 )edit

Hi pthbrk thank you very much for your answer. I have installed the opencv, and I have the libopencv_*.so files here:/usr/lib and the opencv and opencv2 in usr/include I tried this: arm-linux-g++ -H -I/usr/include IPCamera.cpp but the output is hugh and with many errors. My problem is that when I tried to follow the tutorial after this: "git clone https://github.com/Itseez/opencv.git" Ishould make the build with this: "cmake -DSOFTFP=ON -DCMAKE_TOOLCHAIN_FILE=../opencv/platforms/linux/arm-gnueabi.toolchain.cmake ../opencv"

But I get this error:

The CXX compiler identification is unknown -- The C compiler identification is unknown so I cannot finish the cmake.

Any ideas, sorry for my unknowledge and thank you again

Jesus gravatar imageJesus ( 2014-06-11 09:11:45 -0600 )edit

Could I work with /usr/include and usr/lib?

Jesus gravatar imageJesus ( 2014-06-11 09:12:42 -0600 )edit

shall I add those lines in the "arm-gnueabi.toolchain.cmake" file :

SET (CMAKE_C_COMPILER "/opt/freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi") SET (CMAKE_CXX_COMPILER "/opt/freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi")

for finish the cmake

Jesus gravatar imageJesus ( 2014-06-11 09:15:06 -0600 )edit