File not found: mainwindow.obj
c++, qt
Solution
It seems that editstudentdialog.obj file is not created properly. Try to clean the project (Build->Clean all) and the build it again. If it does not help check if editstudentdialog.cpp is added to the SOURCES variable in your .pro file. If still nothing happens please provide the .pro file.
EDIT: As was mentioned below, you may also try to delete the whole app and create it again.
Problem
- I created a GUI Application -> QMainWindow - I added 1 item to the menu + the slot. - I created a new item -> QDialog I the slot method i try to show the created dialog but i get this errors: mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: __cdecl EditStudentDialog::EditStudentDialog(class QWidget *)" (??0EditStudentDialog@@QEAA@PEAVQWidget@@@Z) referenced in function "private: void __cdecl MainWindow::on_actionNew_triggered(void)" (?on_actionNew_triggered@MainWindow@@AEAAXXZ) mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: virtual __cdecl EditStudentDialog::~EditStudentDialog(void)" (??1EditStudentDialog@@UEAA@XZ) referenced in function "private: void __cdecl MainWindow::on_actionNew_triggered(void)" (?on_actionNew_triggered@MainWindow@@AEAAXXZ) This is the main window: ``` #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private slots: void on_actionNew_triggered(); private: Ui::MainWindow *ui; }; #endif // MAINWINDOW_H #include "mainwindow.h" #include "ui_mainwindow.h" #include "editstudentdialog.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_actionNew_triggered() { EditStudentDialog editDialog; editDialog.setModal(true); editDialog.exec(); } ``` This is the dialog ( just an empty one, no controls on it ): ``` #ifndef EDITSTUDENTDIALOG_H #define EDITSTUDENTDIALOG_H #include <QDialog> namespace Ui { class EditStudentDialog; } class EditStudentDialog : public QDialog { Q_OBJECT public: explicit EditStudentDialog(QWidget *parent = 0); ~EditStudentDialog(); private: Ui::EditStudentDialog *ui; }; #endif // EDITSTUDENTDIALOG_H #include "editstudentdialog.h" #include "ui_editstudentdialog.h" EditStudentDialog::EditStudentDialog(QWidget *parent) : QDialog(parent), ui(new Ui::EditStudentDialog) { ui->setupUi(this); } EditStudentDialog::~EditStudentDialog() { delete ui; } ``` What am I doing wrong? EDIT: This is the .pro file ``` QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = GUI1 TEMPLATE = app SOURCES += main.cpp\ mainwindow.cpp \ editstudentdialog.cpp HEADERS += mainwindow.h \ editstudentdialog.h FORMS += mainwindow.ui \ editstudentdialog.ui ``` PS: I tried to clean the project and then build it but still the same issue. EDIT 2: I am using Qt Creator 2.7 with Qt 5.0.2