In this part I’ll show how to build Qt4 with MS Visual C++ 2008 (9.0) Express ( yes, it out there
) :
Requirement:
- MS Visual C++ 2008 (9.0) Express
- Qt/Windows Open Source Edition (.Zip version )
Steps:
- decompress the file to folder of your choose let refer it as QtSource e.g:
- C:\QtSource\
Update: From "Visual Studio 2008 Command Prompt":
- now execute "configure.exe" , to prepare the source
- C:\QtSource> configure
- C:\QtSource> configure
- now run ‘nmake" command , to compile the source ( it will take long time , 1 hour – 4 hours) :
- C:\QtSource> nmake
-
At thing point, you have almost everything ready
, now have a fun playing with the the demos ( QtSource\bin\qtdemo.exe ):- C:\QtSource> cd bin
- C:\QtSource> qtdemo
October 3, 2008 at 22:45
hi man! thank u for this post but i still have a problem with:
3. Edit PATH variable by appending the following path:
;%QTDIR%\bin
i dont get it! what i do in here! then the examples r working good but the compiler dont let me execute couse dont detect the libs and the includes. please a little help i apreciate it too much
October 4, 2008 at 04:40
The perpose of step 3 of "System configure", to make QT(dll’s) visible to any program that need it.
I’m assuming you have successfully done the other steps because it important.
- Now, in the "Environment Variables" window there are two panels one for user variable and other for system.
- From "System Variables", scroll down, to locate "Path" then double click it or select it then click on "Edit"
- From "Edit System Variable" window, add ";%QTDIR%\bin" at the end of Variable value. make sure you have done step 2 in "System configure"
To double check you configuration,in Command Prompt, execute the following command:
"where QtCore4.dll"
You should get the full path of "QtCore4.dll" as an answer.
Note: sometime(never have) you need to restart your PC to get that in effect.
Also, this may help: http://www.youtube.com/…/watch
October 20, 2008 at 14:32
A small convenience :
Make a Qt property sheet and add to Qt related projects.
Create a file Qt.vsprops and paste following
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioPropertySheet
ProjectType="Visual C++"
Version="8.00"
Name="Qt"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""$(QTDIR)\include";"$(QTDIR)\include\QtGui""
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="QtCore4.lib QtGui4.lib"
AdditionalLibraryDirectories=""$(QTDIR)\lib""
/>
<Tool
Name="VCResourceCompilerTool"
AdditionalIncludeDirectories="$(QTDIR)\include"
/>
<UserMacro
Name="QTDIR"
Value="C:\Qt\4.4.3"
PerformEnvironmentSet="true"
/>
</VisualStudioPropertySheet>
For projects using Qt add above property sheet to project.
View->Property Manager then add this file.
October 21, 2008 at 03:02
hi i did what u said, but the error that apears when execute an instance says:
for example for tutorial1 t1.exe
not can find the component
not find QtOpenGLd4.dll. reinstall may help to solve the problem
but i know the installation is fine. couse the qtdemo works, it sopouse that when i build an example in vc++ then i can play a new instance…
or i have to start the instance from console??
October 21, 2008 at 12:40
@suresh: thanks very much, it is a cool and a smart way
BTW, I’m using CMake in all my C++ projects which help in IDE configuration.
@jaime: I think that happen because you are compiling and linking you code in debug mode where your Qt have been compiled as release. In your case, you might re-compile Qt to generate debug files or re-configure the Debug mode to link to Qt’s release one.
I hope that will solve it. Waiting your feedback
January 26, 2009 at 12:55
Hi, I’ve followed your tutorial and set everything up as you’ve stated. In the cmd prompt i can execute "where QtCore4.dll" and get the correct path. When i try and compile a simple test program though,
#include <QApplication>
#include <QPushButton>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QPushButton hello("Hello world!");
hello.show();
return app.exec();
}
this is what it spits out:
1>—— Build started: Project: Test, Configuration: Debug Win32 ——
1>Compiling…
1>Test.cpp
1>c:\users\seth\documents\visual studio 2008\projects\test\test\test.cpp(1) : fatal error C1083: Cannot open include file: ‘QApplication’: No such file or directory
1>Build log was saved at "file://c:\Users\Seth\Documents\Visual Studio 2008\Projects\Test\Test\Debug\BuildLog.htm"
1>Test – 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
not really sure what I’m doing wrong.
January 26, 2009 at 15:54
Hi Seth,
try to change:
#include <QApplication>
#include <QPushButton>
To:
#include <QtGui/QApplication>
#include <QtGui/QPushButton>
Or you can add Qt-modules-include-path to VC++ Environment. To do so,just repeats the steps for configuring "$(QTDIR)\include" to add the following:
* $(QTDIR)\include\QtCore
* $(QTDIR)\include\QtGui
Hopping this will solve yours.
Regards,
January 26, 2009 at 23:57
Thanks for the quick response, my one error turned into 10…
it looks like they are all linker errors.
error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QApplication::~QApplication(void)" (__imp_??1QApplication@@UAE@XZ) referenced in function _main
they all look something like this.
Thanks again for the help.
January 27, 2009 at 08:29
Thats normal
, you just need to specify Qt’s linking libraries(depends on what Qt modules you are using).
For your earlier code, you need to link to:
* QtCore4.lib
* QtGui4.lib
To do so, from project properties:
Configuration Properties –> Linker –> Input –> Additional Dependencies –> add "QtCore4.lib QtGui4.lib" to what you have in there
Anyway, CMake very handy when dealing with Qt configuration specially when using non-default-Qt-modules(other than QtCore & QtGui).
Regards,
January 27, 2009 at 08:33
Btw, have a look to the 3rd comment (by suresh) it a very convenience way to configure you Qt projects.