[SOLVED] qmake - how to correctly setup the .pro file ?



  • Hello,

    I'm writing some classes defined in several files. The test application is defined in a sub directory and I can't correctly setup the .pro file.
    Here is the source tree (don't pay attention to the filenames):
    @c:\Project\QT/
    + Files/
    + file1.cpp
    + file1.h
    + file2.cpp
    + file2.h
    + Lib/
    + lib1.cpp
    + lib1.h
    + lib2.cpp
    + lib2.h
    + TestApp/
    + build-TestApp-Desktop_Qt_5_2_0_MinGW_32bit-Debug/
    + TestApp/
    + TestApp.pro
    + mainwindow.cpp
    + mainwindow.h
    + mainwindow.ui@

    Using QTCreator I added all the header and cpp files into the project and ran qmake. But When I compile the project, the compiler doesn't find <QStringList> which is included in file1.cpp.
    I added INCLUDEPATH is the .pro file and ran qt but it is worth.

    When compiling the files created by qtcreator mainwindow.* anf file1.cpp all the include paths are correctly passed to g++.

    @g++ -c -pipe -fno-keep-inline-dllexport -g -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I..\WeatherTest -I"..........\Qt\5.2.0\mingw48_32\include" -I"..........\Qt\5.2.0\mingw48_32\include\QtWidgets" -I"..........\Qt\5.2.0\mingw48_32\include\QtNetwork" -I"..........\Qt\5.2.0\mingw48_32\include\QtGui" -I"..........\Qt\5.2.0\mingw48_32\include\QtCore" -I"debug" -I"." -I"." -I"..........\Qt\5.2.0\mingw48_32\mkspecs\win32-g++" -o debug\file1.o ......\Files\file1.cpp@

    but when compiling file2 no include paths are specified !!!!

    @g++ -pipe -fno-keep-inline-dllexport -g -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN ../../../Files/file2.cpp -o ../../../Files/file2@

    How Can I add several external source files into Qt without getting mad ?



  • It would help if you posted the content of your pro file.



  • I fixed it.

    the issue was not in the .pro file but in the source files.
    lib2.h included a file named File1 (not file1.h) this file contained
    @#include "file1.h"@

    It seems that when source files include header named with not .h extension, no include paths are passed to g++.


  • Lifetime Qt Champion

    Hi,

    Does File1 exists ?

    When you include a file whether it ends or not with a .h, the file must still exist



  • of course,
    otherwise g++ would tell me it doesn't find the included file.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.