I'm trying to create project structure like below
test/
test.pro
build/
build.pro
main.cpp
gui/
gui.pro
mainwindow.h
mainwindow.cpp
My test.pro looks like this:
TEMPLATE = subdirs
SUBDIRS = gui
CONFIG += ordered
SUBDIRS +=build
build.pro
TEMPLATE = app
QT += core gui
SOURCES += main.cpp
LIBS += -L../gui
gui.pro
TEMPLATE = lib
SOURCES += \
mainwindow.cpp
HEADERS += \
mainwindow.h
mainwindow.cpp
#include "mainwindow.h"
MainWindow::MainWindow(){}
MainWindow::~MainWindow(){}
mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
class MainWindow : public QMainWindow
{
public:
MainWindow();
~MainWindow();
};
#endif // MAINWINDOW_H
main.cpp
#include <QApplication>
#include "gui/mainwindow.h" //error
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
//MainWindow w;
//w.show();
return a.exec();
}
I got an error during compilation:
../../test/build/main.cpp:2:25: error: gui/gui.h: No such file or directory
What am I doing wrong?
Thanks bruno. I changed the line:
#include "gui/mainwindow.h"
to
#include "../gui/mainwindow.h"
But now I have error like below:
undefined reference to `MainWindow::MainWindow()'
undefined reference to `MainWindow::~MainWindow()'
My mainwindow.cpp file looks like below:
#include "mainwindow.h"
MainWindow::MainWindow()
{}
MainWindow::~MainWindow()
{}
How should I add a mainwindow.h file to mainwindow.cpp??