赞
踩
在ubuntu20.04下安装qt5.12.9,方便在电脑上调试正点原子STM32MP157下的qt程序。
sudo tar -xvf gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf.tar
将解压出来的文件移到/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
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
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
cd /qt-everywhere-src-5.12.9/qtbase/mkspecs/linux-arm-gnueabi-g++
编辑qmake.conf , 替换为以下内容。(就是换成刚装的arm版本编译器)
- #
- # 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)
-
- # modifications to g++.conf
- QMAKE_CC = arm-none-linux-gnueabihf-gcc
- QMAKE_CXX = arm-none-linux-gnueabihf-g++
- QMAKE_LINK = arm-none-linux-gnueabihf-g++
- QMAKE_LINK_SHLIB = arm-none-linux-gnueabihf-g++
-
- # modifications to linux.conf
- QMAKE_AR = arm-none-linux-gnueabihf-ar cqs
- QMAKE_OBJCOPY = arm-none-linux-gnueabihf-objcopy
- QMAKE_NM = arm-none-linux-gnueabihf-nm -P
- QMAKE_STRIP = arm-none-linux-gnueabihf-strip
- load(qt_config)
./configure -xplatform linux-arm-gnueabi-g++ -no-opengl
ps: 这里不安装opengl是因为我电脑上没安装opengl
打开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++
手动添加
/usr/local/Qt-5.12.9/bin/qmake
compiler: 选择设置过的arm版本编译器
Qt version:选择设置过的arm版本Qt
默认是x86平台
- 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")
- set(ADDLIB_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib/arm/)
- target_link_libraries(your_project_name PRIVATE
- ${ADDLIB_PATH}/libxxx.so
- )
- else()
- set(ADDLIB_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib/x86/)
- target_link_libraries(your_project_name PRIVATE
- ${ADDLIB_PATH}/libxxx.so
- )
- endif()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。