1。
release/main.o:main.cpp:(.text+0x599): undefined reference to `_imp___ZN12QSqlDatabaseD1Ev'
这个问题是你在qt中使用了数据库,但是在它的项目文件中却没有相应的说明。
解决方法:修改 pro文件加入如下内容:QT += sql
2.make的时候提示出错
mydialog.cpp: In member function `void MyDialog::pb2_cli()':
mydialog.cpp:25: error: expected `)' before "Image"
mydialog.cpp:25: error: missing terminating " character
mydialog.cpp:26: error: expected `;' before '}' token
mingw32-make[1]: *** [release/mydialog.o] Error 1
mingw32-make[1]: Leaving directory `D:/pr'
mingw32-make: *** [release] Error 2
源代码:
filename=QFileDialog::getOpenFileName(this,"open a file","c:/","Image files(*.bmp *.jpg *.gif)") ;
解决方法:把"C:/"替换成"c:"即可
3.mainwindow.cpp:8: error: ISO C++ forbids declaration of `menuopen' with no type
mainwindow.cpp:8: error: prototype for `int MainWindow::menuopen()' does not mat
ch any in class `MainWindow'
代码:
MainWindow::menuopen()
{
QMessageBox::information(this,"abc","bcd");
}
menuopen需要一个返回类型 加上void 或者int就可以解决了
4.release/mydialog.o:mydialog.cpp:(.text+0x9f6): undefined reference to `_imp___ZN
12QSqlDatabase17defaultConnectionE'
release/mydialog.o:mydialog.cpp:(.text+0xa4f): undefined reference to `_imp___ZN
12QSqlDatabase11addDatabaseERK7QStringS2_'
release/mydialog.o:mydialog.cpp:(.text+0xab3): undefined reference to `_imp___ZN
12QSqlDatabaseD1Ev'
代码:QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
解决方法:项目文件中加入对数据库的支持 QT += sql