BreasTouch 在 Linux 下编译及交叉编译到 ARM

BreasTouch 在 Linux 下编译及交叉编译到 ARM

环境

主机环境

  • 硬件
    • 主机:Dell XPS 15 9550
    • CPU:i7-6700HQ @ 2.60GHz
    • GPU 1:Intel(R) HD Graphics 530
    • GPU 2:NVIDIA GeForce GTX 960M
    • 内存:16GB
    • 硬盘:265G SSD + 1TB 机械硬盘
  • 软件
    • 操作系统:Windows 10 教育版

虚拟机环境

  • VMware® Workstation 12 Pro
  • 内存 2GB
  • 处理器 8(4 x 2)
  • 硬盘 200GB
  • openSUSE Tumbleweed
  • Linux localhost 4.15.0-1-default #1 SMP PREEMPT Wed Jan 31 07:03:28 UTC 2018 (ac01747) x86_64 x86_64 x86_64 GNU/Linux

Linux 环境环境编译

安装软件

1
2
sudo zypper install git cmake gcc gcc-c++
sudo zypper install glu-devel

远程桌面

由于客户端软件需要图形界面,所以还需要安装个远程桌面,方便使用:

1
2
3
4
5
sudo apt-get install xrdp
sudo apt-get install vnc4server tightvncserver
cd /home/youruser #youruser 是每个人自己的用户名
echo "gnome-session --session=ubuntu-2d" > .xsession
sudo /etc/init.d/xrdp restart

切换 Python 版本

1
2
3
4
cd /usr/bin
sudo rm python
sudo ln -s python3 python
python --version

安装 Python 库

1
pip install numpy

SSH

查看 SSH 是否已安装:

1
rpm -qa | grep ssh

查看ssh服务是否开启,执行命令:

1
sudo service sshd status

如果未开启,执行

修改 SSH 服务配置

修改 /etc/ssh/sshd_config 中的内容:
将 #PasswordAuthentication no 的注释去掉,并将no改为yes;
保存并退出

关闭防火墙

修改 /etc/sysconfig/SuSEfirewall2 中的内容:
默认下:

1
2
FW_SERVICES_EXT_TCP = ""
FW_SERVICES_EXT_UDP = ""

需要为其添加端口号:

1
2
FW_SERVICES_EXT_TCP = "22"
FW_SERVICES_EXT_UDP = "23"

保存并退出

重启服务

重启防火墙

1
2
sudo service SuSEfirewall2 restart
sudo rcSuSEfirewall2 restart

重启 SSH 服务

1
service sshd start

自动启动 SSH

sudo systemctl enable sshd.service

编译安装 boost

下载 boost 源码压缩包 boost_1_66_0.tar.gz

1
2
3
4
5
tar -zxvf boost_1_66_0.tar.gz
cd boost_1_66_0/
./bootstrap.sh --with-python=/usr/bin/python
./b2 --with-python include="/usr/include/python3.6m"
sudo ./b2 install

安装 Qt5

下载 Qt Linux 版本:http://download.qt.io/official_releases/online_installers/qt-unified-linux-x64-online.run
运行(需设置为可执行,需要图形界面)

注意,Qt5 需要 libGL:

1
sudo zypper install Mesa-libGL-devel

Python

1
sudo zypper install python3-devel

CURL

1
2
3
4
5
6
7
8
sudo zypper install libopenssl-devel
git clone https://github.com/curl/curl.git
cd curl
mkdir build
cd build
cmake ..
make
sudo make install

ZeroMQ

1
2
3
4
5
git clone https://github.com/zeromq/libzmq
cd libzmq
mkdir cmake-build && cd cmake-build
cmake .. && make -j 4
sudo make install && sudo ldconfig

MessagePack

1
2
3
4
5
git clone https://github.com/msgpack/msgpack-c.git
cd msgpack-c && mkdir build && cd build
cmake -DMSGPACK_CXX11=ON ..
make -j 4
sudo make install

QWT

下载 qwt-6.1.3.tar.bz2

1
2
3
4
5
6
bzip2 -d qwt-6.1.3.tar.bz2
tar -xvf qwt-6.1.3.tar
cd qwt-6.1.3
~/Qt/5.9.4/gcc_64/bin/qmake ./qwt.pro
make
sudo make install

libusb

下载 libusb-1.0.22.tar.bz2

1
2
3
4
5
6
bzip2 -d libusb-1.0.22.tar.bz2
tar -xvf libusb-1.0.22.tar
cd libusb-1.0.22/
./configure
make
sudo make install

编译 BreasTouch

1
2
3
4
5
git clone https://gitee.com/boyunfen/breastouch.git
chmod +777 linux_make.sh
./linux_make.sh
cd build
make

直接在华北工控开发板上编译

直接在开发板上编译所需的第三方库,然后在主机上建立交叉编译环境,交叉编译 BreasTouch 项目。

环境准备

切换到中文

系统设置中,使用 Language Support,安装中文语言

升级cmake

1
2
3
4
5
sudo apt-get install git cmake
sudo apt-get install build-essential libudev-dev
sudo apt-get install libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev libegl1-mesa-dev
sudo apt-get install libwayland-egl1-mesa libwayland-dev libqt5waylandclient5-dev
sudo apt-get install libclipper-dev

安装 cmake 3.11

1
2
3
4
5
tar -zxvf cmake-3.11.1.tar.gz
cd cmake-3.11.1
./configure
make
sudo make install

安装 gcc 7.3.0

下载 gcc 最新版源码,解压后进入目录,执行:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
sudo apt-get purge libc6-dev
sudo apt-get install libc6-dev
sudo apt-get install libc6-dev-i386
sudo apt-get install gcc-multilib g++-multilib
sudo apt-get install build-essential

./contrib/download_prerequisites
mkdir gcc-build && cd gcc-build
../configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib:.
make -j 4

sudo apt-get remove gcc gcc-5 #gcc-*的都要卸载了
sudo apt-get remove g++ g++-5 #g++-*的都要卸载了

sudo make install

安装完后重启生效

Qt

1
2
3
./configure -release -nomake examples -nomake tools -nomake tests -prefix /home/jimbo/Qt-arm-5.9.5 -opensource -confirm-license -c++std c++11
make
make install

切换 Python 版本

1
2
3
4
cd /usr/bin
sudo rm python
sudo ln -s python3 python
python --version

Python开发环境

1
2
3
sudo apt-get install python3-dev python3-pip
pip3 install --upgrade pip
pip install numpy

解决pip install 时locale.Error: unsupported locale setting

1
export LC_ALL=C

编译安装 boost

下载 boost 源码压缩包 boost_1_66_0.tar.gz

1
2
3
4
5
6
tar -zxvf boost_1_66_0.tar.gz
cd boost_1_66_0/
./bootstrap.sh --with-python=/usr/bin/python
./b2 -j 4
./b2 --with-python include="/usr/include/python3.5"
sudo ./b2 install

编译完成后,不安装的情况下:

  • include 目录:/home/jimbo/lib/boost_1_66_0
  • library 目录:/home/jimbo/lib/boost_1_66_0/stage/lib

CURL

1
2
3
4
5
6
7
8
9
10
11
sudo apt-get install openssl
sudo apt-get install libssl-dev

git clone https://github.com/curl/curl.git

cd curl
mkdir build
cd build
cmake ..
make
sudo make install

安装后:

1
2
3
4
5
6
7
8
9
10
11
-- Installing: /usr/local/bin/curl-config
-- Installing: /usr/local/lib/pkgconfig/libcurl.pc
-- Installing: /usr/local/include/curl
-- Installing: /usr/local/include/curl/multi.h
-- Installing: /usr/local/include/curl/mprintf.h
-- Installing: /usr/local/include/curl/typecheck-gcc.h
-- Installing: /usr/local/include/curl/stdcheaders.h
-- Installing: /usr/local/include/curl/system.h
-- Installing: /usr/local/include/curl/curlver.h
-- Installing: /usr/local/include/curl/easy.h
-- Installing: /usr/local/include/curl/curl.h

ZeroMQ

1
2
3
4
5
git clone https://github.com/zeromq/libzmq
cd libzmq && mkdir cmake-build && cd cmake-build
cmake .. -DZMQ_BUILD_TESTS=OFF
make -j 6
sudo make install && sudo ldconfig

MessagePack

1
2
3
4
5
git clone https://github.com/msgpack/msgpack-c.git
cd msgpack-c && mkdir build && cd build
cmake -DMSGPACK_CXX11=ON ..
make -j 6
sudo make install

QWT

下载 qwt-6.1.3.tar.bz2

1
2
3
4
5
6
bzip2 -d qwt-6.1.3.tar.bz2
tar -xvf qwt-6.1.3.tar
cd qwt-6.1.3
~/Qt-arm-5.9.5/bin/qmake ./qwt.pro
make
sudo make install

libusb

下载 libusb-1.0.22.tar.bz2

1
2
3
4
5
6
bzip2 -d libusb-1.0.22.tar.bz2
tar -xvf libusb-1.0.22.tar
cd libusb-1.0.22/
./configure
make
sudo make install

Linux 环境下 ARM 交叉编译

1
export PATH=$PATH:/home/jimbo/bin/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf/bin