cross compile opencv-3.4.3 for arm

asked 2018-09-17 05:03:10 -0600

sattu gravatar image

updated 2018-09-17 06:34:48 -0600

Hello all,

I am trying to cross compile openCV 3.4.3 for my arm toolchain by following the steps as mentioned in https://docs.opencv.org/3.4.3/d0/d76/...

Following are the steps-

1) git clone -b 3.4 https://github.com/opencv/opencv

2) cd opencv

4) mkdir build

5) cd build

6) All my tool-chain binaries are present in /usr/local/arm_linux_4.3/usr/bin

7) export PATH=/usr/local/arm_linux_4.3/usr/bin:$PATH

8) cmake -DCMAKE_INSTALL_PREFIX:PATH=/home/realand/opencv/build/install -DCMAKE_C_COMPILER=arm-linux-uclibcgnueabi-gcc -DCMAKE_CXX_COMPILER=arm-linux-uclibcgnueabi-g++ -DCMAKE_LINKER=arm-linux-uclibcgnueabi-ld -DCMAKE_AR=arm-linux-uclibcgnueabi-ar -DSOFTFP=ON -DCMAKE_TOOLCHAIN_FILE=/home/realand/opencv/platforms/linux/arm-gnueabi.toolchain.cmake /home/realand/opencv

But I am getting too many errors in the above step. This is the first time I am using cmake to cross compile a library. So I am not at all familiar with it's working.

Now that I am getting so many errors how do I proceed? Following is the output-

-- The CXX compiler identification is GNU 5.3.4
-- The C compiler identification is GNU 4.3.4
-- Check for working CXX compiler: /usr/local/arm_linux_4.3/usr/bin/arm-linux-uclibcgnueabi-g++
-- Check for working CXX compiler: /usr/local/arm_linux_4.3/usr/bin/arm-linux-uclibcgnueabi-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working C compiler: /usr/local/arm_linux_4.3/usr/bin/arm-linux-uclibcgnueabi-gcc
-- Check for working C compiler: /usr/local/arm_linux_4.3/usr/bin/arm-linux-uclibcgnueabi-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Performing Test HAVE_CXX11 (check file: cmake/checks/cxx11.cpp)
-- Performing Test HAVE_CXX11 - Failed
-- Found PythonInterp: /usr/bin/python2.7 (found suitable version "2.7.6", minimum required is "2.7")
-- Could NOT find PythonLibs (missing:  PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS) (Required is at least version "2.7")
-- Cannot probe for Python/Numpy support (because we are cross-compiling OpenCV)
-- If you want to enable Python/Numpy support, set the following variables:
--   PYTHON2_INCLUDE_PATH
--   PYTHON2_LIBRARIES (optional on Unix-like systems)
--   PYTHON2_NUMPY_INCLUDE_DIRS
--   PYTHON3_INCLUDE_PATH
--   PYTHON3_LIBRARIES (optional on Unix-like systems)
--   PYTHON3_NUMPY_INCLUDE_DIRS
-- Found PythonInterp: /usr/bin/python3.4 (found suitable version "3.4", minimum required is "3.4")
-- Could NOT find PythonLibs (missing:  PYTHON_LIBRARIES) (Required is at least version "3.4")
-- Cannot probe for Python/Numpy support (because we are cross-compiling OpenCV)
-- If you want to enable Python/Numpy support, set the following variables:
--   PYTHON2_INCLUDE_PATH
--   PYTHON2_LIBRARIES (optional on Unix-like systems)
--   PYTHON2_NUMPY_INCLUDE_DIRS
--   PYTHON3_INCLUDE_PATH
--   PYTHON3_LIBRARIES (optional on Unix-like systems)
--   PYTHON3_NUMPY_INCLUDE_DIRS
-- Looking for ccache - not found
-- Performing Test HAVE_CXX_FSIGNED_CHAR
-- Performing Test HAVE_CXX_FSIGNED_CHAR - Failed
-- Performing Test HAVE_C_FSIGNED_CHAR
-- Performing Test HAVE_C_FSIGNED_CHAR - Failed
-- Performing Test HAVE_CXX_W
-- Performing Test HAVE_CXX_W - Failed
-- Performing Test HAVE_C_W
-- Performing Test HAVE_C_W - Failed
-- Performing Test HAVE_CXX_WALL
-- Performing Test HAVE_CXX_WALL - Failed
-- Performing Test HAVE_C_WALL
-- Performing Test HAVE_C_WALL - Failed
-- Performing Test HAVE_CXX_WERROR_RETURN_TYPE
-- Performing Test HAVE_CXX_WERROR_RETURN_TYPE - Failed
-- Performing Test HAVE_C_WERROR_RETURN_TYPE
-- Performing Test HAVE_C_WERROR_RETURN_TYPE - Failed
-- Performing Test HAVE_CXX_WERROR_NON_VIRTUAL_DTOR
-- Performing Test HAVE_CXX_WERROR_NON_VIRTUAL_DTOR - Failed
-- Performing Test HAVE_C_WERROR_NON_VIRTUAL_DTOR
-- Performing Test HAVE_C_WERROR_NON_VIRTUAL_DTOR - Failed
-- Performing Test HAVE_CXX_WERROR_ADDRESS
-- Performing Test HAVE_CXX_WERROR_ADDRESS - Failed
-- Performing Test HAVE_C_WERROR_ADDRESS
-- Performing Test HAVE_C_WERROR_ADDRESS - Failed
-- Performing Test HAVE_CXX_WERROR_SEQUENCE_POINT
-- Performing Test HAVE_CXX_WERROR_SEQUENCE_POINT - Failed
-- Performing Test HAVE_C_WERROR_SEQUENCE_POINT
-- Performing ...
(more)
edit retag flag offensive close merge delete

Comments

why 1) ?

also git clone https://github.com/opencv/opencv is the masterr branch.

imho you should replace 1)-3) by:

git clone -b 3.4 https://github.com/opencv/opencv
cd opencv
mdir build
cd build
... run cmake, and come back with the output ! (please put that into your question, NOT a comment)
berak gravatar imageberak ( 2018-09-17 05:27:11 -0600 )edit

also:

CMAKE_INSTALL_PREFIX:PATH

should point to, where you want the final binaries/headers, so probably:

/home/myUser/opencv-3.4.3/build/install
berak gravatar imageberak ( 2018-09-17 05:30:17 -0600 )edit

But I am getting too many errors in the above step.

we can only help, if you TELL us the errors...

berak gravatar imageberak ( 2018-09-17 05:31:13 -0600 )edit
1

Hello @berak, I have updated my post.

sattu gravatar imagesattu ( 2018-09-17 06:18:30 -0600 )edit

try to disable everything python related (you can't cross-compile the python bindings anyway) e.g. :

cmake -DBUILD_opencv_python=OFF

and all Performing Test HAVE_ warnings/errors are irrelevant.

berak gravatar imageberak ( 2018-09-17 06:20:05 -0600 )edit

Ok, let me try that. One more doubt I have. I also try compiling using cmake-gui but get following error - "cmake-gui: cannot connect to X server"

sattu gravatar imagesattu ( 2018-09-17 06:25:44 -0600 )edit

Cross compiling OpenCV is a real PITA. I think it's better to compile it directly on the ARM computer. It will take a while (but even on a Raspberry Pi 1 it takes less than 10 hours).

So while you figure out how to set up your cross-compile chain with all the dependencies, it's already built locally.

kbarni gravatar imagekbarni ( 2018-09-17 07:20:39 -0600 )edit

Any plans on enhancing cmake to better support cross-compile, if so when?

I observer that cmake has hardcoded /usr/include and /usr/local for search paths, I went thru all my *.cmake files to allow my cross-compile to work, but my make fails on resize.cpp compile errors.

Thanks

tbuckley gravatar imagetbuckley ( 2019-01-08 08:55:50 -0600 )edit