This article will explain the process of crossing OpenCV3.0.0 and QT5.5.1 in the Ubuntu environment. The target platform is Raspberry Pi 2
First build a cross -compilation environment for Raspberry Pi,
cd /opt
mkdir tools
git clone git://github.com/raspberrypi/tools.git tools
Detailed process refer to http://shumeipai.nxez.com/2013/10/08/configure- Compiler-platform-raspberry-pi.html
download OpenCV3.0.0 source code, decompress it under the CV300 folder, and enter the directory
cd /home/samba/cv300
Create a file called Toolchain.cmake under the path of the source code, and enter the following information in this file and save it.
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_C_COMPILER arm-bcm2708hardfp-linux-gnueabi-gcc)
set(CMAKE_CXX_COMPILER arm-bcm2708hardfp-linux-gnueabi-g++)
Next use Cmake to generate a makefile file.
cd /home/samba/cv300
mkdir build
cd build
cmake -D CMAKE_TOOLCHAIN_FILE=../toolchain.cmake -D CMAKE_INSTALL_PREFIX=/usr/cv300 ../
and then run the CCMAKE command to enter the parameter settings UI (if there is no CCMAKE, you can install it through the APT Install CMAKE-CURSES-GUI), and set various environmental variables and parameters as needed. After setting, you can use Make && Make Install -J4 to compile the source code and generate and install the related library files.
At the directory/usr/cv300, there is related library files and header files. All the contents of this directory can be copied to the corresponding directory of the raspberry mirror image. And add a line of the directory/usr/cv300 at the end of the file /etc/ld.so.conf, save it, and then run LDCONFIG in the terminal. That is, the transplantation of OpenCV3 is completed on the Raspberry Pi 2.
Of course, you can also make all the contents of the directory/USR/CV300 into a mirror file and mount them on the raspberry school system.
qt5.5.1 transplantation process
Press the source code of QT5.5.1 to the folder/Home/Samba/QT551, enter the folder, and according to the directory/Home/Samba/qt551/qtbase/MKSpecs/Devices/Linux-Rasp-Pi2-G ++ The content of qmake.conf is to modify the qmake.comf under the/home/samba/qtbase/MKSpecs/Linux-GNUEABI-G ++ directory to modify it as shown below and save it.
#
# qmake configuration for building with arm-linux-gnueabi-g++
#
MAKEFILE_GENERATOR = UNIX
CONFIG += incremental
QMAKE_INCREMENTAL_STYLE = sublib
include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)
QT_QPA_DEFAULT_PLATFORM = linuxfb
QMAKE_LIBS_EGL = -lEGL -lGLESv2
QMAKE_CFLAGS += -march=armv7-a -marm -mthumb-interwork -mfpu=neon-vfpv4 -mtune=cortex-a7 -mabi=aapcs-linux
QMAKE_CXXFLAGS = $$QMAKE_CFLAGS
DISTRO_OPTS += hard-float
# Preferred eglfs backend
EGLFS_DEVICE_INTEGRATION = eglfs_brcm
# modifications to g++.conf
QMAKE_CC = arm-bcm2708hardfp-linux-gnueabi-gcc
QMAKE_CXX = arm-bcm2708hardfp-linux-gnueabi-g++
QMAKE_LINK = arm-bcm2708hardfp-linux-gnueabi-g++
QMAKE_LINK_SHLIB = arm-bcm2708hardfp-linux-gnueabi-g++
# modifications to linux.conf
QMAKE_AR = arm-bcm2708hardfp-linux-gnueabi-ar cqs
QMAKE_OBJCOPY = arm-bcm2708hardfp-linux-gnueabi-objcopy
QMAKE_NM = arm-bcm2708hardfp-linux-gnueabi-nm -P
QMAKE_STRIP = arm-bcm2708hardfp-linux-gnueabi-strip
load(qt_config)
Enter the directory/Home/Samba/QT551, use commands according to actual needs ./configure for configuration
cd /home/samba/qt551
./configure -opensource -confirm-license -prefix /usr/qt551 -xplatform linux-arm-gnueabi-g++ -no-pch -optimized-qmake -nomake examples
The configuration is compiled and installed with Make && Make Install -J4. After completion, some related folders will be existed under the directory/usr/qt551. Copy all the files in this directory to the corresponding directory of Raspberry Pi mirror to complete the transplantation of QT5.5.1.
Attachment of IMG image
dd if=/dev/zero of=qt551.img bs=1M count=230
mkfs.ext2 -F qt551.img
chmod +w qt551.img
mount qt551.img -o loop /mnt
cp -rf /usr/qt551/* /mnt
umount /mnt
Copy the mirror to the Raspberry Pi and mount it in the/USR/QT551 directory.