qte终于移植成功,但是在交叉编译自己写的程序是总是提示有错误,错误如下:In file included from main.cpp:3:
./database.h:3:23: QSqlDatabase: No such file or directory
./database.h:4:20: QSqlQuery: No such file or directory
In file included from main.cpp:3:
./database.h: In function `bool createConnection()':
./database.h:8: error: `QSqlDatabase' was not declared in this scope
./database.h:8: error: expected `;' before "db"
./database.h:9: error: `db' was not declared in this scope
./database.h:8: warning: unused variable 'QSqlDatabase'
make: *** [main.o] 错误
提示没有这两个文件或目录?明明在我的include里面怎么会没有?我想尽一切办法,又是该边境变量,又是删除编译文件重新编译,最后还是不行,我一遍一遍的查看include目录,最后发现错误提示的两个文件在include/QtSql/下面所以我就把程序的包含文件目录该了一下原来为:#include<QSqlDatabase>,#include<QSqlQuery>改过后为:#include<QtSql/QSqlDatabase>,#include<QtSql/QSqlQuery>就是在原来的基础上增加一个目录前缀,这样问题就解决了,这个编译通过,但是下面又出现了错误,错误如下:songlist.cpp:6:20: QSqlQuery: No such file or directory
songlist.cpp:12: error: `songlist' has not been declared
songlist.cpp:12: error: ISO C++ forbids declaration of `songlist' with no type
songlist.cpp: In function `int songlist(QWidget*)':
songlist.cpp:12: error: only constructors take base initializers
songlist.cpp:16: error: `ui' was not declared in this scope
songlist.cpp:16: error: invalid use of `this' in non-member function
songlist.cpp:20: error: `model' was not declared in this scope
songlist.cpp:20: error: `QSqlTableModel' has not been declared
songlist.cpp:20: error: invalid use of `this' in non-member function
songlist.cpp:31: error: `model2' was not declared in this scope
songlist.cpp:31: error: `QSqlTableModel' has not been declared
songlist.cpp:31: error: invalid use of `this' in non-member function
songlist.cpp: At global scope:
songlist.cpp:46: error: expected constructor, destructor, or type conversion before '::' token
songlist.cpp:51: error: `songlist' is not a class or namespace
songlist.cpp: In function `void changeEvent(QEvent*)':
songlist.cpp:53: error: cannot call member function `virtual void QWidget::changeEvent(QEvent*)' without object
songlist.cpp:56: error: `ui' was not declared in this scope
songlist.cpp:56: error: invalid use of `this' in non-member function
songlist.cpp:56: warning: unused variable 'ui'
songlist.cpp: At global scope:
songlist.cpp:63: error: `songlist' is not a class or namespace
songlist.cpp: In function `void on_pushButton_clicked()':
songlist.cpp:65: error: `ui' was not declared in this scope
songlist.cpp:70: error: `model' was not declared in this scope
songlist.cpp:80: error: `model2' was not declared in this scope
songlist.cpp:65: warning: unused variable 'ui'
songlist.cpp: At global scope:
songlist.cpp:87: error: `songlist' is not a class or namespace
songlist.cpp: In function `void on_pushButton_4_clicked()':
songlist.cpp:89: error: `ui' was not declared in this scope
songlist.cpp:90: error: `model2' was not declared in this scope
songlist.cpp:92: error: `Dir' was not declared in this scope
songlist.cpp:93: error: `prefix' was not declared in this scope
songlist.cpp:94: error: `PATH' was not declared in this scope
songlist.cpp:97: error: `play1' was not declared in this scope
songlist.cpp:97: warning: unused variable 'play1'
songlist.cpp: At global scope:
songlist.cpp:103: error: `songlist' is not a class or namespace
songlist.cpp: In function `void on_pushButton_3_clicked()':
songlist.cpp:105: error: `ui' was not declared in this scope
songlist.cpp:106: error: `model2' was not declared in this scope
songlist.cpp:105: warning: unused variable 'ui'
songlist.cpp: At global scope:
songlist.cpp:110: error: `songlist' is not a class or namespace
songlist.cpp: In function `void on_pushButton_2_clicked()':
songlist.cpp:115: error: invalid use of `this' in non-member function
database.h: At global scope:
database.h:7: warning: 'bool createConnection()' defined but not used
make: *** [songlist.o] 错误
交叉编译真是让人头大啊!从错误开始的地方找,添加头目录,发现问题还是没有解决,于是就查看songlist.h发现里面什么东西都没了,还提示任何的改动都可能造成文件内容丢失,于是就重新建立了一个工程,继续交叉编译,前面的问题都解决了 ,但是又出现了新的错误,错误如下:main.o: In function `main':
main.cpp:(.text+0x210): undefined reference to `QSqlQuery::~QSqlQuery()'
main.cpp:(.text+0x220): undefined reference to `QSqlDatabase::~QSqlDatabase()'
main.cpp:(.text+0x794): undefined reference to `QSqlDatabase::addDatabase(QString const&, QString const&)'
main.cpp:(.text+0x858): undefined reference to `QSqlDatabase::~QSqlDatabase()'
main.cpp:(.text+0xbac): undefined reference to `QSqlDatabase::setDatabaseName(QString const&)'
main.cpp:(.text+0xc48): undefined reference to `QSqlDatabase::open()'
main.cpp:(.text+0xcf0): undefined reference to `QSqlQuery::~QSqlQuery()'
main.cpp:(.text+0xd00): undefined reference to `QSqlDatabase::~QSqlDatabase()'
main.cpp:(.text+0xd68): undefined reference to `QSqlDatabase::QSqlDatabase()'
main.cpp:(.text+0xd80): undefined reference to `QSqlQuery::QSqlQuery(QString const&, QSqlDatabase)'
main.cpp:(.text+0xd90): undefined reference to `QSqlDatabase::~QSqlDatabase()'
main.cpp:(.text+0xe98): undefined reference to `QSqlQuery::exec(QString const&)'
main.cpp:(.text+0xef8): undefined reference to `QSqlDatabase::defaultConnection'
main.cpp:(.text+0xf90): undefined reference to `QSqlQuery::exec(QString const&)'
main.cpp:(.text+0x1038): undefined reference to `QSqlQuery::exec(QString const&)'
main.cpp:(.text+0x10e0): undefined reference to `QSqlQuery::exec(QString const&)'
main.cpp:(.text+0x1188): undefined reference to `QSqlQuery::exec(QString const&)'
main.cpp:(.text+0x1230): undefined reference to `QSqlQuery::exec(QString const&)'
main.o:main.cpp:(.text+0x12d8): more undefined references to `QSqlQuery::exec(QString const&)' follow
songlist.o: In function `songlist::songlist(QWidget*)':
songlist.cpp:(.text+0x1ac): undefined reference to `QSqlQuery::~QSqlQuery()'
songlist.cpp:(.text+0x47c): undefined reference to `QSqlDatabase::~QSqlDatabase()'
songlist.cpp:(.text+0x5b0): undefined reference to `QSqlDatabase::QSqlDatabase()'
songlist.cpp:(.text+0x5d8): undefined reference to `QSqlTableModel::QSqlTableModel(QObject*, QSqlDatabase)'
songlist.cpp:(.text+0x5f4): undefined reference to `QSqlDatabase::~QSqlDatabase()'
songlist.cpp:(.text+0x7c0): undefined reference to `QSqlDatabase::QSqlDatabase()'
songlist.cpp:(.text+0x7e8): undefined reference to `QSqlTableModel::QSqlTableModel(QObject*, QSqlDatabase)'
songlist.cpp:(.text+0x804): undefined reference to `QSqlDatabase::~QSqlDatabase()'
songlist.cpp:(.text+0x8cc): undefined reference to `QSqlQueryModel::query() const'
songlist.cpp:(.text+0x9d0): undefined reference to `QSqlQuery::~QSqlQuery()'
songlist.o: In function `songlist::songlist(QWidget*)':
songlist.cpp:(.text+0xbb8): undefined reference to `QSqlQuery::~QSqlQuery()'
songlist.cpp:(.text+0xe88): undefined reference to `QSqlDatabase::~QSqlDatabase()'
songlist.cpp:(.text+0xfbc): undefined reference to `QSqlDatabase::QSqlDatabase()'
songlist.cpp:(.text+0xfe4): undefined reference to `QSqlTableModel::QSqlTableModel(QObject*, QSqlDatabase)'
songlist.cpp:(.text+0x1000): undefined reference to `QSqlDatabase::~QSqlDatabase()'
songlist.cpp:(.text+0x11cc): undefined reference to `QSqlDatabase::QSqlDatabase()'
songlist.cpp:(.text+0x11f4): undefined reference to `QSqlTableModel::QSqlTableModel(QObject*, QSqlDatabase)'
songlist.cpp:(.text+0x1210): undefined reference to `QSqlDatabase::~QSqlDatabase()'
songlist.cpp:(.text+0x12d8): undefined reference to `QSqlQueryModel::query() const'
songlist.cpp:(.text+0x13dc): undefined reference to `QSqlQuery::~QSqlQuery()'
songlist.o: In function `songlist::on_pushButton_clicked()':
songlist.cpp:(.text+0x2f38): undefined reference to `QSqlTableModel::submitAll()'
songlist.o: In function `songlist::on_pushButton_4_clicked()':
songlist.cpp:(.text+0x43d0): undefined reference to `QSqlTableModel::submitAll()'
songlist.o: In function `songlist::on_pushButton_3_clicked()':
songlist.cpp:(.text+0x47b8): undefined reference to `QSqlTableModel::submitAll()'
collect2: ld returned 1 exit status
make: *** [SKTV] 错误
这样错误在交叉编译QTE时,出现了一个类似的,但是我重新解压再编译时却没有了 ,我在网上也没找到类似的问题,所以我只好再重新编译了,相同的错误还是出现,先静下心来想想,一夜没有睡好!
终于解决了,问题终于解决了。问题原因:由于交叉编译是使用qte的qmake -project手动建立的工程文件,无法自动判断是否包含数据库,所以我们如果使用了数据库既要手动在工程文件的最后添加一句话,QT +=sql这样问题就迎刃而解了,困扰了我好几天的错误,也是最关键的错误,如果无法解决,整个程序将无法编译和移植!啊,松了一口气!
分享到:
相关推荐
Qt程序交叉编译.zip
ARM64下QT需要用到QWebEngine模块,网上很多资源交叉编译QT时,均默认跳过此步骤,没跳过此步骤的很多未能详细提供交叉编译webengine模块所依赖的库,导致此模块无法交叉编译通过,资源中包含了arm64下交叉编译的...
在window下编写qt程序(helloworld.pro),在linux下编译helloworld.pro,生成可执行文件并上传至树莓派上运行
在linux系统上,用自带的交叉编译工具对openssl源码进行交叉编译(该过程可参考百度),生成对应的静态和动态库,然后将生成的库拷贝至arm设备的QT库锁存放的位置,这样的目的是当我们在设备上跑qt程序时,使用https...
基于CentOS7 系统下的 ARM 开发板 QT 交叉编译工具,使CentOS7 系统下编译的 QT 程序能够运行在 ARM 开发板上。
利用arm-linux-gcc 4.5.1 交叉编译器编译Qt5.4.2的过程文档
Qt4.8.4 搭建交叉编译环境,应用程序可以在MPC8315EVB上运行
飞腾上银河麒麟编译qt5.9.8,使用aarch64-linux-gnu-g++,可以在飞腾直接编译,也可交叉编译
基于嵌入式QT的车载影音系统应用,通过交叉编译Qt程序,并在GEC6818开发板上运行.zip 基于嵌入式QT的车载影音系统应用,通过交叉编译Qt程序,并在GEC6818开发板上运行.zip 基于嵌入式QT的车载影音系统应用,通过交叉...
刁肥宅自己编译的Qt 5.7.0的静态编译库,亲测用这个库编译的exe程序,不需要任何dll和其他附加文件便可以在不带Qt环境的电脑上运行。
在ubuntu上进行嵌入式的开发,我们大部分采用的是上位机进行交叉编译程序,移植到目标主机(下位机)进行运行,这时我们可以在qt上进行配置我们的交叉编译环境,然后在qt这个IDE上进行编写,编译,然后在下位机上运行...
国产系统 统信uos20 飞腾cpu qt5.14源码编译 静态版本
arm-xilinx-linux-gnueabi 交叉编译工具链。可在编译ZED Board等其他使用ZYNQ芯片的系统的内核时使用
5.列表框,交叉编译QT程序,QT控制硬件,多进程
配置编译qt-everywhere-src-5.12.7安装交叉编译链已配置好TSLIB编译注意事项配置编译qt源码执行脚本对于硬浮点设置相关参数配置QTCreator打开选项添加qmake添加已安装的arm版本交叉编译工具链最后组合下PS:对于强迫...
在ubuntu14下,使用友善之臂4.4.3交叉编译的qt4.6.3lib,放到/lib下就可以在板子上跑qt程序了
涵盖了QT交叉编译ARM架构程序,在手动打包的时候常缺少的.so库,直接拷贝到打包的lib目录下即可解决缺少库的问题。
说明: 本工具链的制作运行环境是macOS Monterey 12.5.1 适用目标机Asus AX86U路由器 本工具链中各软件版本: binutils 2.28.1 glibc 2.26 Linux 4.1.52 gcc 12.2.0 gdb 12.1.0 gmp 6.2.1 mpfr 4.1.0 ...
该文件是对qt-everywhere-opensource-src-5.9.9.tar使用-linux-gnu-交叉编译后的安装文件,可以直接下载到zynqmp上运行,不需要对源码重新编译,里面包括了各种交叉库以及linuxfb、minimal、offscreen、vnc等插件。...
内含源码包、编译包、安装完成的库. ...如遇到qt程序在客户机报xcb错误,可以先交叉编译此文件夹的包,再在qt源码配置中启用xcb,并指定依赖库位置。请注意:交叉编译qt时,不能引用系统的库,指令集不一致