Results 1 to 4 of 4

Thread: qmake and including files doubt

  1. #1
    Join Date
    Aug 2008
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default qmake and including files doubt

    Hi!
    I have a doubt about using .pro files.

    I'm using QT4 under win32 with codeblocks to develop my apps.
    I've been developing in c before using QT and never had this strange behaviour.
    The basic question is, I need to use the #include directive if I add those files in .pro file??

    Cause I'm have not clear the whole concept of how this works, I'm constantly problems every time I add a new file to the project and spent a lot of time trying to "hack" every file to get it work.

    For example, the last problem I've got was a "multiple declaration" error at compile time.
    I added a new class:
    MapWidget.h
    Qt Code:
    1. #include <QGLWidget>
    2.  
    3. class MapWidget : public QGLWidget
    4. {
    5. Q_OBJECT
    6.  
    7. public:
    8. MapWidget( int timerInterval=0, QWidget* parent=0, char* name=0 );
    9.  
    10. protected:
    11. void initializeGL();
    12. void resizeGL( int width, int height );
    13. void paintGL();
    14.  
    15. };
    To copy to clipboard, switch view to plain text mode 

    MapWidget.c
    Qt Code:
    1. #include "MapWidget.h"
    2.  
    3. MapWidget::MapWidget( int timerInterval, QWidget* parent, char* name)
    4. {
    5. }
    6.  
    7. void MapWidget::initializeGL()
    8. {
    9. }
    10.  
    11. void MapWidget::resizeGL( int width, int height )
    12. {
    13. }
    14.  
    15. void MapWidget::paintGL()
    16. {
    17. }
    To copy to clipboard, switch view to plain text mode 

    Then in another already working file, I add MapWidget.c.
    This causes the "multiple declaration" error over every MapWidget method.
    I checked every file in the project and I don't duplicate the include of MapWidget.c .
    If I delete the #include "graphics/MapWidget.c" then all compiles correctly.

    What's wrong!?

    This is my .pro file:
    Qt Code:
    1. TEMPLATE = app
    2. TARGET =
    3. DEPENDPATH += . comm debug forms graphics release
    4. QT += opengl
    5. CONFIG += console
    6. CONFIG += qt debug
    7. DESTDIR = bin/
    8. INCLUDEPATH += .
    9. # Input
    10. FORMS += forms/gepeese.ui forms/gps_config.ui
    11. HEADERS += definitions.h \
    12. GuiGPS.hpp \
    13. comm/GPScomm.hpp \
    14. comm/NMEA.hpp \
    15. comm/SerialPort.hpp \
    16. forms/ConfigGPS.hpp \
    17. graphics/MapWidget.hpp
    18. SOURCES += GuiGPS.cpp \
    19. main.cpp \
    20. comm/GPScomm.cpp \
    21. comm/NMEA.cpp \
    22. comm/SerialPort.cpp \
    23. forms/ConfigGPS.cpp \
    24. graphics/MapWidget.cpp
    25. RESOURCES += resources.qrc
    To copy to clipboard, switch view to plain text mode 

    PD:Sorry about my english.

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: qmake and including files doubt

    INCLUDEPATH and DEPENDPATH should look like
    Qt Code:
    1. INCLUDEPATH += ./comm \
    2. ./forms \
    3. ./graphics
    4. DEPENDPATH += ./comm \
    5. ./forms \
    6. ./graphics
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Aug 2008
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qmake and including files doubt

    Oh, that solved my "multiple declaration" problem!
    Thank you, that part was automatically generated by qmake -project.

    Anyway, I still don't understand the whole concept of qmake.

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: qmake and including files doubt

    that is what in qmake-reference is written:
    qmake is a tool from Trolltech that helps simplify the build process for development project across different platforms. qmake automates the generation of Makefiles so that only a few lines of information are needed to create each Makefile. qmake can be used for any software project, whether it is written in Qt or not.
    qmake generates a Makefile based on the information in a project file. Project files are created by the developer, and are usually simple, but more sophisticated project files can be created for complex projects. qmake contains additional features to support development with Qt, automatically including build rules for moc and uic. qmake can also generate projects for Microsoft Visual studio without requiring the developer to change the project file.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.