文章目录
前言
最近工作中要求客户端和服务端通过ssl加密通信,其中客户端是qt编程,服务端是linux编程.我的开发环境是ubuntu16.04;运行环境是debian9.13,是基于gnu的linux操作系统,64位arm架构.
一、编译安装openssl
首先要确定qt版本对应的openssl版本,我使用的是qt5.7.1+openssl1.0.2,如果qt和openssl版本不对应,后面编译qt会编译失败.
下载openssl-1.0.2.tar.gz,下载地址:
链接: https://pan.baidu.com/s/1R3AWkoXBn7kxFCyZhuW7Jw
提取码: hw7w
然后依次执行如下命令:
cpp
tar -zxvf openssl-1.0.2.tar.gz
cd openssl-1.0.2
./config no-asm shared --prefix=/opt/W6460-openssl-qt-lib/openssl-1.0.2-build/ --cross-compile-prefix=/opt/tools/gcc-linaro-6.3.1-2017.05-i686_aarch64-linux-gnu/bin/aarch64-linux-gnu-
sed -i 's/-m64/ /g' Makefile
make -j4
sudo make install
编译完成后,如下:
二、编译qt5.7.1
下载qt-everywhere-opensource-src-5.7.1-source.tar.gz,下载地址:
链接: https://pan.baidu.com/s/10o5WwzJF2HVPLvbUV8dSCg
提取码: inmi
执行如下命令:
cpp
tar -zxvf qt-everywhere-opensource-src-5.7.1-source.tar.gz
cd qt-everywhere-opensource-src-5.7.1-source/qtbase/mkspecs
查看是否存在aarch64-linux-gnu-g++文件夹,如不存在,则复制arm-linux-gnueabihf-g++到aarch64-linux-gnu-g++
然后执行如下命令:
cpp
cd aarch64-linux-gnu-g++
vi qmake.config
修改内容如下:
cpp
#
# qmake configuration for building with arm-linux-gnueabihf-g++
#
MAKEFILE_GENERATOR = UNIX
CONFIG += incremental
QMAKE_INCREMENTAL_STYLE = sublib
QT_QPA_DEFAULT_PLATFORM = linuxfb
include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)
# modifications to g++.conf
QMAKE_CC = aarch64-linux-gnu-gcc
QMAKE_CXX = aarch64-linux-gnu-g++
QMAKE_LINK = aarch64-linux-gnu-g++
QMAKE_LINK_SHLIB = aarch64-linux-gnu-g++
# modifications to linux.conf
QMAKE_AR = aarch64-linux-gnu-ar cqs
QMAKE_OBJCOPY = aarch64-linux-gnu-objcopy
QMAKE_NM = aarch64-linux-gnu-nm -P
QMAKE_STRIP = aarch64-linux-gnu-strip
load(qt_config)
在qt源码父目录,新建一个build.sh文件,内容如下:
cpp
#!/bin/sh
export W6460_QT_INSTALL=/opt/W6460-openssl-qt-lib
export PKG_CONFIG_LIBDIR=/opt/tools/gcc-linaro-6.3.1-2017.05-i686_aarch64-linux-gnu/aarch64-linux-gnu/lib64
export CROSS_COMPILE=aarch64-linux-gnu-
Cur_Dir=$(pwd)
QT_SORCE=qt-everywhere-opensource-src-5.7.1-source
echo $Cur_Dir
export W6460_QT_BUILD=$Cur_Dir
export PATH=$W6460_QT_INSTALL/bin:$PATH
cd $QT_SORCE
./configure -xplatform aarch64-linux-gnu-g++ \
-opensource \
-confirm-license \
-I/opt/W6460-openssl-qt-lib/openssl-1.0.2-build/include \
-L/opt/W6460-openssl-qt-lib/openssl-1.0.2-build/lib -lssl -lcrypto \
-skip qtquickcontrols \
-skip qtactiveqt \
-skip qtandroidextras \
-skip qtdeclarative \
-skip qtimageformats \
-skip qtmacextras \
`#-skip qtserialport` \
-skip qtx11extras \
-skip qtxmlpatterns \
-skip qtconnectivity \
-skip qtdoc \
-skip qtgraphicaleffects \
-skip qtlocation \
`#-skip qtmultimedia` \
-skip qtsensors \
-skip qttools \
-skip qttranslations \
-skip qtwayland \
`#-skip qtwebchannel` \
`#-skip qtwebengine` \
`#-skip qtwebsockets` \
-skip qtwinextras \
-verbose \
`#-no-gif` \
`#-no-libjpeg` \
-qt-libjpeg \
-qt-libpng \
-no-mtdev \
-no-sql-db2 \
-no-sql-ibase \
-no-sql-mysql \
-no-xcb \
-qt-freetype \
-fontconfig \
-no-harfbuzz \
-no-xinput2 \
-no-xcb-xlib \
-no-pulseaudio \
-no-alsa \
-no-cups \
-no-iconv \
-no-icu \
-no-eglfs \
-no-dbus \
-prefix $W6460_QT_INSTALL
make -j4
sudo make install
然后,执行命令:
cpp
./build.sh
等待编译结果...
三、配置qtcreator开发环境
四、demo