Note that there are some explanatory texts on larger screens.

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

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload