I cross compiled OpenCV for a Xilinx Zinq ARM system yesterday by more-or-less following the steps outlined in the above document – I had to change a few things to get the build to work. I am documenting the exact steps that I took in case anybody is having trouble (probably future me!).
I started with a fairly clean Ubuntu install on a virtual machine (it already had git installed) , first I installed some build tools, feel free to skip any that you already have:
sudo apt-get install build-essential sudo apt-get install cmake
Then I installed the GNU ARM tool-chain:
sudo apt-get install gcc-arm-linux-gnueabi sudo apt-get install g++-arm-linux-gnueabi
This installed version 4.7 of the compilers while the build process calls for version 4.6, to get around this I modified the cmake platform file slightly, see below.
Create a build directory, cd into it and get the OpenCV source from github:
mkdir opencv_build cd opencv_build git clone https://github.com/Itseez/opencv.git
To fix the version problem I modified the compiler version in the platform file (this may not be the most correct way to do this but it worked for me!):
I edited this file:
I changed the GCC_COMPILER_VERSION variable’s value from 4.6 to 4.7 to match my installed compiler. I had to edit the file as I wasn’t able to override these variables from the command line.
Now create a sub-directory called build and cd into it:
mkdir build cd build
And configure the build:
cmake -DSOFTFP=ON -DCMAKE_TOOLCHAIN_FILE=../opencv/platforms/linux/arm-gnueabi.toolchain.cmake ../opencv
This should complete without errors if you have the compiler that it is looking for installed etc.
Now run ‘make’ and ‘make install’:
make make install
Make will take a few minutes to run, make install should copy the output files to a subdirectory called ‘install’.
All being well you should now have all the include and lib files that you need to build an OpenCV app for your ARM device.