Thursday, May 31, 2007

Creating .exe using Qmake from QT

Well, didn't find time to write anything or think about writing anything because of loads of issues.

This blog mainly deals with the issue of how to create .exe files when one is using qt libs in code.
A well documented fact which I am putting online for my own reference or rather easy reference. I have taken this from QT faq's long time back. So I don't have the reference link for it.

Suppose one has placed all the files in QPainter folder and wants to create the executable file or a VC project file.

1) Creating Exe.
Qmake –project
Open QPainter.pro and add CONFIG += thread
Qmake –win32 QPainter.pro // This will create a makefile
Nmake –f Makefile

Warning regarding LNK4199 is given but exe still gets created.
Now just run the exe created.


2) For VC++, again after making the above changes in configuration file.

Qmake –project
Open QPainter.pro and add CONFIG += thread
Qmake –t vcapp QPainter.pro –o QPainter.dsp

Now open the dsp in vc, it still will give qt.lib error.
Now edit QPainter.dsp // wow no one told me about this one. tried on my own

In there , there is variable ADD LINK32 which has path to qt.lib. Change qt.lib to qt-mt.lib.

Now the code will run but will give a warning LNK4098:defaultlib “msvcrt.lib” conflicts with use of other libs …

The warning and erors may or may not occur. I have added them because they occurred when I was trying out the executable or VC project creation.


Programming Ring - New Post
Programming Ring - Old Post