作者归档:xinlu

Android添加第三方库

if(ANDROID)
    # the follow VARIABLE must be written before find_package or it will be no effective.
    # must add CACHE INTERNAL parameter. or it will failed.
    message("add the third so library to project")
    #set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android" CACHE INTERNAL "")
    set(ANDROID_EXTRA_LIBS "${LIBSSH_SOURCE_PATH}/lib/libssh.so" CACHE INTERNAL "")
    message("ANDROID_EXTRA_LIBS=${ANDROID_EXTRA_LIBS}")
endif()

The CACHE is mandatory, otherwise QtCreator won’t see the variable and it won’t use it

Qt5.12.8ForAndroid

如果只是使用Qt自身提供的组件,而不引入第三方组件,则建议使用Window系统,因为Qt和Android支持得非常成熟。
但一旦需要引入第三方库时,建议使用ubuntu进行开发。因为官方的linux版本,也是基于ubuntu来开发的。
而在选择ubuntu的版本是非常重要,因为选择错误是经常无法正常启动模拟器或调试的。
本人也是在使用ubuntu20.04/ubuntu18.10/ubuntu19.x/Centos7.x等,吃心苦头后仍不得结果,才开始思考如何让系统顺利运行包括单步调试/编译openssl/zib等第三方组等
核心关健点:只要能找到官方原生编译系统的环境或配置,并重现该环境,则一定能成功单步调试/自由编译第三方组件
首先,官方仓库是没有发现任何编译脚本。
只能通过源码搜索,检查系统的蛛丝马迹了。
我是按以下方法找到最佳系统版本的。
第一步:下载最新的LTS版本Qt5.12.8的Linux版本,随便找一个linux系统安装,包括源码。
第二步:在源码目录下:搜索“grep -r ‘ubuntu’ ./”,然后它会显示下以下一些信息。

第三步:从输出的信息中,可以确认Qt5.12.8是在ubuntu18.04环境下编译的。
事实上也验证在18.04中安装确实是成功实现单步调试和自由编译第三方包的体验。
以下是安装过程的总结:
1.安装准备
>>Ubuntu18.04,安装后,需要把软件源切换至阿里源。
>>Qt5.12.x最新版【5.12.x只选择LTS版,因为LTS版是Linux系统最常用的,问题最少且最快被修复的版本】
>>AndroidStudio3.5.2版,【从r25开始,AndroidSDK只随IDE一起发布,且SDK结构也与旧版有较大差异。】
>>JDK1.8.x版本。
2.系统安装【VMWare虚拟机安装】。
系统安装,Ubuntu18.04安装成功后,按以下步骤开启GPU和CPU加速,这是android模拟器需要VT-x和图形3D加速


切换软件源


3.安装Qt5.12.8【当前最新版】。把所有组件全部选择上。
4.安装JDK1.8.x版本。
5.安装AndroidStudio,本人选择的是AndroidStudio3.5.2版本,目标是SDK,但从R24版本后的SDK工具是和IDE捆绑一起。
从SDKr24版后,SDK工具已经发生比较大的变化,且不再独立发布,且结构也发生比较大的变化且不兼容,这需要特别注意。
我是默认安装了Android-10
6.配置Qt的Android。

===========================================================
问题列表
问题一:无法创建模拟器,如下图:

需要安装相应的SytemImage,如下图所示【从Android8以后,模拟器主要是提供x86模拟器,而Arm是直接连接设备即可,既然是模拟器那是哪一种模拟器就不重要了】:

=————————————-
问题二:
Android SDK启动提示:Failed to load module “canberra-gtk-module”
sudo apt-get install libcanberra-gtk-module
————————————————
问题三:
Linux环境下,如下报如下错:
cannot find -lGL
collect2:error:ld returned 1 exit status
sudo apt-get install libgl1-mesa-dev
—————————
问题三:
gcc无法使用
ubuntu:
报错When executing step “Make”
sudo apt-get install build-essential
—————————————–

JETBRAIN/phpstorm/golang/clion的永久激活码

推荐方法是:
http://kxtry.com/upload/jetbrains-agent.tar.gz

V0Z5FCVKUI-eyJsaWNlbnNlSWQiOiJWMFo1RkNWS1VJIiwibGljZW5zZWVOYW1lIjoi5rC45LmF5r+A5rS7IGlkZWEubWVkZW1pbmcuY29tIiwiYXNzaWduZWVOYW1lIjoiIiwiYXNzaWduZWVFbWFpbCI6IiIsImxpY2Vuc2VSZXN0cmljdGlvbiI6IiIsImNoZWNrQ29uY3VycmVudFVzZSI6ZmFsc2UsInByb2R1Y3RzIjpbeyJjb2RlIjoiSUkiLCJwYWlkVXBUbyI6IjIwMjAtMDUtMTMiLCJleHRlbmRlZCI6ZmFsc2V9LHsiY29kZSI6IkFDIiwicGFpZFVwVG8iOiIyMDIwLTA1LTEzIiwiZXh0ZW5kZWQiOmZhbH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RmiAVRE/EKwIDAQABo4GZMIGWMAkGA1UdEwQCMAAwHQYDVR0OBBYEFGEpG9oZGcfLMGNBkY7SgHiMGgTcMEgGA1UdIwRBMD+AFKOetkhnQhI2Qb1t4Lm0oFKLl/GzoRykGjAYMRYwFAYDVQQDDA1KZXRQcm9maWxlIENBggkA0myxg7KDeeEwEwYDVR0lBAwwCgYIKwYBBQUHAwEwCwYDVR0PBAQDAgWgMA0GCSqGSIb3DQEBCwUAA4ICAQAF8uc+YJOHHwOFcPzmbjcxNDuGoOUIP+2h1R75Lecswb7ru2LWWSUMtXVKQzChLNPn/72W0k+oI056tgiwuG7M49LXp4zQVlQnFmWU1wwGvVhq5R63Rpjx1zjGUhcXgayu7+9zMUW596Lbomsg8qVve6euqsrFicYkIIuUu4zYPndJwfe0YkS5nY72SHnNdbPhEnN8wcB2Kz+OIG0lih3yz5EqFhld03bGp222ZQCIghCTVL6QBNadGsiN/lWLl4JdR3lJkZzlpFdiHijoVRdWeSWqM4y0t23c92HXKrgppoSV18XMxrWVdoSM3nuMHwxGhFyde05OdDtLpCv+jlWf5REAHHA201pAU6bJSZINyHDUTB+Beo28rRXSwSh3OUIvYwKNVeoBY+KwOJ7WnuTCUq1meE6GkKc4D/cXmgpOyW/1SmBz3XjVIi/zprZ0zf3qH5mkphtg6ksjKgKjmx1cXfZAAX6wcDBNaCL+Ortep1Dh8xDUbqbBVNBL4jbiL3i3xsfNiyJgaZ5sX7i8tmStEpLbPwvHcByuf59qJhV/bZOl8KqJBETCDJcY6O2aqhTUy+9x93ThKs1GKrRPePrWPluud7ttlgtRveit/pcBrnQcXOl1rHq7ByB8CFAxNotRUYL9IF5n3wJOgkPojMy6jetQA5Ogc8Sm7RG6vg1yow==

CMake的目录输出

也许是CMake的版本问题,某些时候以下配置只需要配置其中一项就可以达到目的,有的根本无效。
—————————————————————-
———-这是Window的特色设置,在Linux中只需要一个CMAKE_INSTALL_PREFIX即可—————-
—————————————————————
以下是几乎百分百有效的配置。

SET(CMAKE_EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
SET(CMAKE_EXECUTABLE_OUTPUT_PATH_DEBUG ${PROJECT_SOURCE_DIR}/bin)
SET(CMAKE_EXECUTABLE_OUTPUT_PATH_RELEASE ${PROJECT_SOURCE_DIR}/bin)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/bin)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/bin)
SET(CMAKE_LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
SET(CMAKE_LIBRARY_OUTPUT_PATH_DEBUG ${PROJECT_SOURCE_DIR}/bin)
SET(CMAKE_LIBRARY_OUTPUT_PATH_RELEASE ${PROJECT_SOURCE_DIR}/bin)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/bin)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/bin)

Qt项目。
cmake -A x64 -T host=x64 ../wotermt生成vc工程。
cmake –build . –config Release采用Release编译。

openssl的编译

因为应用是跨平台,所以openssl的版本选择很重要,最好是应用使用的版本是与linux系统一致的。
当前Centos7.x已经开始使用1.0.2的版本,且官方也因为linux的广泛使用,也会一直维护该分支版。
打开其发布的版本页,找到1.0.2的最新版本:
https://github.com/openssl/openssl/releases

1.下载https://github.com/openssl/openssl/archive/OpenSSL_1_0_2u.tar.gz
2.解压并检查其下INSTALL.XXX文件,因为目标是WIN64,所以选择INSTALL.W64并按它的步骤下载相关组件及编译。
3.以下是摘取出来

 To build for Win64/x64:

 > perl Configure VC-WIN64A --prefix=c:\some\openssl\dir
 > ms\do_win64a
 > nmake -f ms\ntdll.mak
 > cd out32dll
 > ..\ms\test

4.仍需要下载并安装NASM工具,这个工具是INSTALL.WXX没有说及的。
http://www.nasm.us/pub/nasm/releasebuilds/2.14.02/
附带完整的编译脚本
build_static_openssl_x64.bat

echo "init vc env"
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
set path_script=%~dp0
set path=C:\Users\honey\AppData\Local\bin\NASM;%path%
cd /D %path_script%\openssl_1_0_2u
perl Configure VC-WIN64A --prefix=%path_script%\lib\static
call ms\do_win64a
nmake -f ms\nt.mak clean
nmake -f ms\nt.mak
nmake -f ms\nt.mak install
nmake -f ms\nt.mak test

build_shared_openssl_x64.bat

echo "init vc env"
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
set path_script=%~dp0
set path=C:\Users\honey\AppData\Local\bin\NASM;%path%
cd /D %path_script%\openssl_1_0_2u
perl Configure VC-WIN64A --prefix=%path_script%\lib\shared
call ms\do_win64a
nmake -f ms\ntdll.mak clean
nmake -f ms\ntdll.mak
nmake -f ms\ntdll.mak install
nmake -f ms\ntdll.mak test

Qt的CMakefiles样本1

cmake_minimum_required(VERSION 3.1)

project(untitled3 LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Qt5 COMPONENTS core widgets REQUIRED)

add_executable(${PROJECT_NAME} "main.cpp" "qml.qrc")
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Widgets)
##特别注意是Qt5而不是Qt

the difference between vt100 and vt102

The VT102 was a member of the “second generation” of the VT100 family.
The original VT100 was sold with a number of options that could be inserted
into the box. The most significant was the AVO, or Advanced Video Option,
which was pretty much just extra memory. The base VT100 supported a 24×80
mode and a 14×132 mode. It supported normal text plus one video attribute,
which could be either underlining or reverse-video – which one you got
depended on whether you selected an underline or box cursor. AVO gave you
24×132 mode and the full four video attributes (underline, reverse, bold,
blink). The VT100 also had a modem control option, providing extra RS-232
signals.
The VT102 was a closed system (no options) which provided the equivalent of
a VT100 plus AVO plus (I think) modem control. It also added one or two
new commands – if I remember correctly, “Insert Line” (open a new line,
scroll stuff below it down) and “Delete Line”, and perhaps “Insert” and
“Delete Character in Line”.
DEC many years ago *defined* “VT100 compatibility” as “equivalent to a
VT102”. All subsequent DEC products that claimed VT100 compatibility
actually supported the full 24×132 display mode, four video attributes, and
the additional commands. (Modem control is a separate issue – “VT100
compatibility” is usually taken to refer only to *software* compatibility.)
As far as I know, the industry has pretty much followed DEC’s definition,
except that many terminal emulators are incapable of properly supporting
the 132-wide mode due to limitations of their displays.
There is absolutely no difference between the keypads of VT100’s and
VT102’s.

miniserver配置

version: '3.1'

services:
  mysql:
    image: mysql:5.6.40
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: 123456
    # links:
    ports:
      - 3306:3306
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - /opt/mysql/data:/var/lib/mysql

  redis:
    image: docker.io/redis:latest
    restart: always
    ports:
      - 6379:6379

  redis-cluster:
    image: grokzen/redis-cluster:5.0.7
    restart: always
    environment:
      STANDALONE: 'true'
      IP: '0.0.0.0'
    ports:
      - '7000-7050:7000-7050'
      - '5000-5010:5000-5010'
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro

  prometheus:
    image: prom/prometheus:v2.15.2
    restart: always
    ports:
      - 9090:9090