当前位置:   article > 正文

Ubuntu安装qt5.12.9以及配置交叉编译环境_qt-opensource-linux-x64-5.12.9

qt-opensource-linux-x64-5.12.9

1.简介

在ubuntu20.04下安装qt5.12.9,方便在电脑上调试正点原子STM32MP157下的qt程序。

2.交叉编译器

2.1下载

https://mirrors.tuna.tsinghua.edu.cn/armbian-releases/_toolchain/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf.tar.xzhttps://mirrors.tuna.tsinghua.edu.cn/armbian-releases/_toolchain/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf.tar.xz

2.2解压

sudo tar -xvf gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf.tar

2.3安装

将解压出来的文件移到/usr/local/arm

sudo cp -r gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf /usr/local/arm/

添加环境变量:在~/.bashrc中添加

export PATH=$PATH:/usr/local/arm/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin

再source

source ~/.bashrc

3.QT

3.1先安装桌面版本qt

Index of /archive/qt/5.12/5.12.9https://download.qt.io/archive/qt/5.12/5.12.9/

下载 qt-opensource-linux-x64-5.12.9.run 然后安装

sudo chmod 777 qt-opensource-linux-x64-5.12.9.run
./qt-opensource-linux-x64-5.12.9.run

3.2安装arm版本qt

Index of /archive/qt/5.12/5.12.9/singlehttps://download.qt.io/archive/qt/5.12/5.12.9/single/

解压

tar -xvf qt-everywhere-src-5.12.9.tar.xz
  • step2 修改配置文件
cd /qt-everywhere-src-5.12.9/qtbase/mkspecs/linux-arm-gnueabi-g++

 编辑qmake.conf , 替换为以下内容。(就是换成刚装的arm版本编译器)

  1. #
  2. # qmake configuration for building with arm-linux-gnueabi-g++
  3. #
  4. MAKEFILE_GENERATOR = UNIX
  5. CONFIG += incremental
  6. QMAKE_INCREMENTAL_STYLE = sublib
  7. include(../common/linux.conf)
  8. include(../common/gcc-base-unix.conf)
  9. include(../common/g++-unix.conf)
  10. # modifications to g++.conf
  11. QMAKE_CC = arm-none-linux-gnueabihf-gcc
  12. QMAKE_CXX = arm-none-linux-gnueabihf-g++
  13. QMAKE_LINK = arm-none-linux-gnueabihf-g++
  14. QMAKE_LINK_SHLIB = arm-none-linux-gnueabihf-g++
  15. # modifications to linux.conf
  16. QMAKE_AR = arm-none-linux-gnueabihf-ar cqs
  17. QMAKE_OBJCOPY = arm-none-linux-gnueabihf-objcopy
  18. QMAKE_NM = arm-none-linux-gnueabihf-nm -P
  19. QMAKE_STRIP = arm-none-linux-gnueabihf-strip
  20. load(qt_config)
  • step3 /qt-everywhere-src-5.12.9 下开终端输入以下指令,先输入o再输入y
./configure -xplatform linux-arm-gnueabi-g++ -no-opengl

ps:        这里不安装opengl是因为我电脑上没安装opengl

  • step4 sudo make -j16
  • step5 sudo make install

3.3配置qt

打开qt,点击工具->选项->kits , 先改编译器

  • 编译器

点击添加->GCC->C++ , 名称自己取,编译器路径复制以下

/usr/local/arm/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-g++
  • Qt version

手动添加

/usr/local/Qt-5.12.9/bin/qmake
  • kits

compiler: 选择设置过的arm版本编译器

Qt version:选择设置过的arm版本Qt

PS:Qt 中 , cmake 库文件选择

默认是x86平台

  1. if ("${CMAKE_CXX_COMPILER}" STREQUAL "/usr/local/arm/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-gcc")
  2. set(ADDLIB_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib/arm/)
  3. target_link_libraries(your_project_name PRIVATE
  4. ${ADDLIB_PATH}/libxxx.so
  5. )
  6. else()
  7. set(ADDLIB_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib/x86/)
  8. target_link_libraries(your_project_name PRIVATE
  9. ${ADDLIB_PATH}/libxxx.so
  10. )
  11. endif()

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/138505
推荐阅读
相关标签
  

闽ICP备14008679号