128.配置qt(交叉)编译的路径---解决无法编译的问题

今天遇到一个问题:

我自己(因为懒)不想编译qt5的交叉编译环境了(用x86电脑编译运行在arm64的qt程序),所以我就从同事那里拷贝一个环境。

正确的做法是解压他的环境,然后用他相同的路径,这样基本能正常编译成功。

但是只要跟对方的路径不一致,就不行(错误见3,qmake都不能正常执行)。

然后另一个同事说,可以解决。

于是就准备动手试试。

1. 先说解决办法:

在解压的路径(已经是自己想要放置的路径了,具体路径看下图)下设置一个qt.conf文件,内容就是设置Prefix的值(参考下图),路径内容就是图中这个bin文件的上一级!

注意,这个路径不是我同事那个qt编译时的路径了,而是我自己想要放置的路径了。

复制代码
dazhi@jc-mypc:~/cross_compillers/qt5.12.8/bin$ cat qt.conf
[Paths]
Prefix=/home/dazhi/cross_compillers/qt5.12.8


dazhi@jc-mypc:~/cross_compillers/qt5.12.8/bin$ pwd
/home/dazhi/cross_compillers/qt5.12.8/bin
dazhi@jc-mypc:~/cross_compillers/qt5.12.8/bin$ ls
canbusutil        moc           qlalr             qmllint        qt.conf                qvkgen     xmlpatterns
fixqt4headers.pl  qdbus         qmake             qmlmin         qtattributionsscanner  rcc        xmlpatternsvalidator
lconvert          qdbuscpp2xml  qml               qmlscene       qtdiag                 repc
lrelease          qdbusviewer   qmlcachegen       qmltestrunner  qtpaths                syncqt.pl
lupdate           qdbusxml2cpp  qmlimportscanner  qscxmlc        qtplugininfo           uic
dazhi@jc-mypc:~/cross_compillers/qt5.12.8/bin$ ls ..
bin  include  mkspecs  qml                       translations          virtualkeyboard
doc  lib      plugins  qt-everywhere-src-5.12.8  virtual_keyboard_app
dazhi@jc-mypc:~/cross_compillers/qt5.12.8/bin$

2. qt路径调试的方法

qmake -query 可以查看环境变量是否正常,当我看到下图这个时,我就知道这是我想要的了。

因为跟我的解压路径一致。

编译的时候,这些头文件的路径都是自己设置的路径,就没问题了

3.这是路径不一致的时候就报的错误:

无法qmake ,之后我也没有make,因为无法生成makefile。

复制代码
dazhi@jc-mypc:/mnt/g/desktop/HJ25426/build-arm64-Programmable_Key_Configuration_Test_Qt5-2$ /home/dazhi/cross_compillers/qt5.12.8/bin/qmake ../Programmable_Key_Configuration_Test_Qt5/Programmable_Key_Configuration_Test_Qt5.pro
Could not find qmake spec 'linux-aarch64-gnu-g++'.
Error processing project file: ../Programmable_Key_Configuration_Test_Qt5/Programmable_Key_Configuration_Test_Qt5.pro
dazhi@jc-mypc:/mnt/g/desktop/HJ25426/build-arm64-Programmable_Key_Configuration_Test_Qt5-2$ linux
linux32  linux64
dazhi@jc-mypc:/mnt/g/desktop/HJ25426/build-arm64-Programmable_Key_Configuration_Test_Qt5-2$ linux
linux32  linux64
dazhi@jc-mypc:/mnt/g/desktop/HJ25426/build-arm64-Programmable_Key_Configuration_Test_Qt5-2$ linux
linux32  linux64
dazhi@jc-mypc:/mnt/g/desktop/HJ25426/build-arm64-Programmable_Key_Configuration_Test_Qt5-2$ /home/dazhi/cross_compillers/qt5.12.8/bin/qmake -spec /home/dazhi/cross_compillers/qt5.12.8/mkspecs/linux-aarch64-gnu-g++ ../Programmable_Key_Configuration_Test_Qt5/Programmable_Key_Configuration_Test_Qt5.pro
Project ERROR: Could not find feature force_asserts.
dazhi@jc-mypc:/mnt/g/desktop/HJ25426/build-arm64-Programmable_Key_Configuration_Test_Qt5-2$

这样就可以解决很多可以偷懒的问题了,哈哈,感谢同事tjy的技术支持!!!

相关推荐
初阳7851 天前
【Qt】SQLite——数据库介绍
数据库·qt·sqlite
Quz2 天前
QML 信号与槽:直接绑定与跨文件通信
qt·编程语言·设计
GIS阵地2 天前
QgsSingleBandPseudoColorRenderer 完整详解(QGIS 3.40.13 C++)
开发语言·前端·c++·qt·qgis
丰锋ff2 天前
1.2 Qt常用基础类型
开发语言·qt
nianniannnn2 天前
Qt QMessageBox知识点
开发语言·数据库·qt
J_yyy2 天前
【Qt核心组件类框架】
开发语言·qt
Drone_xjw2 天前
双网卡下Qt程序数据包“乱飞”之谜:为什么必须断开再连接
开发语言·qt
Quz2 天前
QML 网格与流式布局:Grid/GridLayout 与 Flow
qt
qq_401700412 天前
Qt容器性能优化:QVector、QHash、QMap到底应该怎么选?
开发语言·qt·性能优化
Quz2 天前
QML 线性布局:Row/RowLayout 与 Column/ColumnLayout
前端·qt