PDA

View Full Version : Problem with QMake/UIC



hardgeus
28th February 2008, 20:31
I have been using SCONS for my build environment so far, and recently switched to qmake. I have yet to solve the following problem, and I couldn't find an answer in the forum search.

uic is not executed on my ui files when I build. My .pro is as follows:


TEMPLATE = app
CONFIG = qt warn_on debug
CONFIG += uic3

HEADERS = config.h frmMain.h tinystr.h tinyxml.h

SOURCES = frmMain.cpp main.cpp tinystr.cpp tinyxml.cpp tinyxmlerror.cpp tinyxmlparser.cpp

;INCLUDEPATH += C:\\Qt\\4.1.1\\include
;INCLUDEPATH += C:\\postgresql\\include

LIBS += -lQtCore4 -lQtGui4 -lQtSql4 -lQtNetwork4
win32 {
LIBS += -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwsock32 -lws2_32
}
unix {
; SOURCES += hellounix.cpp
}

FORMS += frmMain_template.ui
INTERFACES += frmMain_template.ui

TARGET = hardupdater


I run the following:

# qmake

(This builds a Makefile)

# make

I am on a Ubuntu box with QT4, but the problem remains on both MingW/Windows/QT4 and Gentoo/QT4

I have tried having only one or the other of FORMS/INTERFACES, and have tried both uic3 and uic4 under the config.

I have also tried modifying the "expected" output header that I include from my .cpp file. With my SCONS build, I was including:

#include "frmMain_template.h"

From the output of a manually run uic, it seems that I might need to expect:

#include "Ui_frmMain_template.h"

One of the links I found through Google indicated that unless a .cpp file requires the corresponding header, UIC will not be run, but I have tried everything above to no success.

wysota
28th February 2008, 20:39
You don't need to add anything to config to have uic available. Uic generates files in form of "ui_formname.h" (with lowercase "u", which might be relevant for uic).

hardgeus
28th February 2008, 20:46
You don't need to add anything to config to have uic available. Uic generates files in form of "ui_formname.h" (with lowercase "u", which might be relevant for uic).

uic is not being run at all. I modified my code this time to include "ui_frmmain_template.h", which based on what you said should be the filename, re-ran qmake, re-ran make, and uic is still not run on my .ui file. During compilation I get errors because ui_frmmain_template.h is not found.

wysota
28th February 2008, 21:00
uic is not being run at all. I modified my code this time to include "ui_frmmain_template.h", which based on what you said should be the filename, re-ran qmake, re-ran make, and uic is still not run on my .ui file. During compilation I get errors because ui_frmmain_template.h is not found.

Try this project file:

SOURCES+=main.cpp
FORMS += form.ui

And in main.cpp:


#include "ui_form.h"

int main(){
return 0;
}

BTW. I think line 2 of your project file may be invalid. You write "CONFIG=..." instead of "CONFIG+=...".

hardgeus
28th February 2008, 21:38
BTW. I think line 2 of your project file may be invalid. You write "CONFIG=..." instead of "CONFIG+=...".

Hmm...it turns out that's the problem. If I modify my first line to be CONFIG +=, then everything works as expected.

ChristianEhrlicher
29th February 2008, 06:47
You also don't need all the LIBS += - it's just confusing :)

hardgeus
31st March 2008, 15:51
I don't know if it's considered bad form to bump old threads, but I figured I'd just continue this one since my issue is unchanged, and it is really affecting my ability to efficiently develop with QT. Apparently, I was only masking an underlying issue when I changed my .pro file as described above. Something weird is definitely happening.

On my Ubuntu box, uic will run *only* if my config line has a += as follows:

CONFIG += qt warn_off debug

The "+" is the key to making it work. If I leave off the "+", uic will not run. Ever.

To make matters even more confusing, on my Windows box, uic will only run if I have the "+" *and* I remove the first line:

TEMPLATE = app

Unfortunately, in Windows, if I remove this line uic will run but now my .exe is not built. On Linux, everything runs just fine without this line.

My .pro is still as described above. What is going on? I have scoured documentation, and I cannot find anything that begins to explain this behavior.

(Edited to add current .pro file)


CONFIG += qt warn_off debug

HEADERS = frmAdministrative.h frmEvaluation.h frmLIneItem.h frmLocation.h frmLogin.h frmMain.h qtutil.h tinystr.h tinyxml.h xmlhandler.h jonconfig.h claimobject.h

SOURCES = frmAdministrative.cpp frmEvaluation.cpp frmLineItem.cpp frmLocation.cpp frmLogin.cpp frmMain.cpp main.cpp qtutil.cpp tinystr.cpp tinyxml.cpp tinyxmlerror.cpp tinyxmlparser.cpp xmlhandler.cpp jonconfig.cpp claimobject.cpp

INCLUDEPATH += C:\\Qt\\4.1.1\\include
INCLUDEPATH += C:\\postgresql\\include

win32 {
LIBS += -lQtCore4 -lQtGui4 -lQtSql4 -lQtNetwork4 -lQtXml
LIBS += -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwsock32 -lws2_32
LIBS += -ladvapi32
}
unix {
LIBS += -lQtCore -lQtGui -lQtSql -lQtNetwork -lQtXml
}


INTERFACES += frmAdministrative_template.ui
INTERFACES += frmEvaluation_template.ui
INTERFACES += frmLineItem_template.ui
INTERFACES += frmLocation_template.ui
INTERFACES += frmLogin_template.ui
INTERFACES += frmMain_template.ui

TARGET = estitrac

wysota
31st March 2008, 16:58
You can't overwrite CONFIG as it contains declarations vital for Qt code to be built correctly. You can only add to it or remove from it.

After having a quick look at the above file, it could be shortened to:

CONFIG += warn_off debug

HEADERS = frmAdministrative.h frmEvaluation.h frmLIneItem.h frmLocation.h \
frmLogin.h frmMain.h qtutil.h tinystr.h tinyxml.h xmlhandler.h jonconfig.h claimobject.h

SOURCES = frmAdministrative.cpp frmEvaluation.cpp frmLineItem.cpp frmLocation.cpp frmLogin.cpp \
frmMain.cpp main.cpp qtutil.cpp tinystr.cpp tinyxml.cpp tinyxmlerror.cpp \
tinyxmlparser.cpp xmlhandler.cpp jonconfig.cpp claimobject.cpp

win32:INCLUDEPATH += C:/postgresql/include

QT += sql network xml

FORMS += frmAdministrative_template.ui frmEvaluation_template.ui frmLineItem_template.ui \
frmLocation_template.ui frmLogin_template.ui frmMain_template.ui

TARGET = estitrac

hardgeus
31st March 2008, 18:22
Your .pro file works fine for me in Ubuntu, but not in Windows.

Using your .pro file, the uic does get executed properly. However, in Windows, no .exe file is generated at the last step. No errors are reported. Even if I add the "TEMPLATE = app" line, it still will not generate a .exe

hardgeus
31st March 2008, 18:27
OK, I am an idiot. I didn't see the debug\ and release\ subdirectories. The .exe is being generated, but the default directory structure is different on Windows. Is there documentation on how I can change where the binary is generated?

jpn
31st March 2008, 18:33
See DESTDIR (http://doc.trolltech.com/4.3/qmake-variable-reference.html#destdir).

hardgeus
31st March 2008, 18:51
OK, all is well with the world. Thanks, guys!