PDA

View Full Version : qmake and including files doubt



clinisbut
16th August 2008, 14:57
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


#include <QGLWidget>

class MapWidget : public QGLWidget
{
Q_OBJECT

public:
MapWidget( int timerInterval=0, QWidget* parent=0, char* name=0 );

protected:
void initializeGL();
void resizeGL( int width, int height );
void paintGL();

};


MapWidget.c


#include "MapWidget.h"

MapWidget::MapWidget( int timerInterval, QWidget* parent, char* name)
{
}

void MapWidget::initializeGL()
{
}

void MapWidget::resizeGL( int width, int height )
{
}

void MapWidget::paintGL()
{
}


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:


TEMPLATE = app
TARGET =
DEPENDPATH += . comm debug forms graphics release
QT += opengl
CONFIG += console
CONFIG += qt debug
DESTDIR = bin/
INCLUDEPATH += .
# Input
FORMS += forms/gepeese.ui forms/gps_config.ui
HEADERS += definitions.h \
GuiGPS.hpp \
comm/GPScomm.hpp \
comm/NMEA.hpp \
comm/SerialPort.hpp \
forms/ConfigGPS.hpp \
graphics/MapWidget.hpp
SOURCES += GuiGPS.cpp \
main.cpp \
comm/GPScomm.cpp \
comm/NMEA.cpp \
comm/SerialPort.cpp \
forms/ConfigGPS.cpp \
graphics/MapWidget.cpp
RESOURCES += resources.qrc


PD:Sorry about my english.

spirit
16th August 2008, 15:05
INCLUDEPATH and DEPENDPATH should look like


INCLUDEPATH += ./comm \
./forms \
./graphics
DEPENDPATH += ./comm \
./forms \
./graphics

clinisbut
16th August 2008, 15:24
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.

spirit
16th August 2008, 15:40
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.