PDA

View Full Version : Issued in HelloWorld QT programming



sankar
10th February 2011, 04:29
1. Installed VS2008 completely.

2. Installed QT 4.5.0.

3. Tried to setup the following user environment variables,
PATH => C:\Qt\4.5.0\bin
QMAKESPEC => win32-msvc2008
QTDIR => C:\Qt\4.5.0

4. Tried sample HelloWorld program as shown below,
a. Created a hello folder

b. Created hello.cpp and copied the following code into it,
/************************************************** ****/
// HelloWorld
/************************************************** ****/
#include <QApplication>
#include <QLabel>

int main(int arg c, char* argv[])
{
QApplication app(argc, arv);
QLabel *myLabel = new QLabel("Hello World");
myLabel->show();
return app.exec();
}
/************************************************** ****/
c. From command prompt, changed the directory to hello, and type qmake -project to create a platform-independent project file (hello.pro). hello.pro file is created successfully.

d. Ran qmake hello.pro, to create a platform-specific makefile from the project file. But it throws the following error,
C:\Qt Samples\hello>qmake hello.pro
Error processing meta file: c:\Qt\4.5.0\lib\qtmain
Error processing meta file: c:\Qt\4.5.0\lib\qtmaind
Error processing meta file: c:\Qt\4.5.0\lib\qtmain

5. Then tried HelloWorld progam from VisualStudio as shown below,
a. First added QT path in VC++ Directories
Executables - $(QTDIR)\bin
Include - $(QTDIR)\include
Lib - $(QTDIR)\lib
Source - $(QTDIR)\src

b. Created a new project (File-> New-> Project-> General-> Makefile Project) named HelloQt.
Then modified configuration settings as given below,
Go to Project-> Properties-> Configuration Properties-> Nmake and enter the following in the build command line qmake -project && qmake && nmake release-all. Also enter release\HelloQt.exe in the Output field.

c. Added HelloQt.cpp and copied the above HelloWorld program.

d. Tried to build it, but it throws the following error,
/************************************************** ****************************************/
// Build Output window
/************************************************** ****************************************/
1>------ Build started: Project: HelloQt, Configuration: Release Win32 ------
1>Performing Makefile project actions
1>Error processing meta file: c:\Qt\4.5.0\lib\qtmain
1>Error processing meta file: c:\Qt\4.5.0\lib\qtmaind
1>Error processing meta file: c:\Qt\4.5.0\lib\qtmain
1>Microsoft (R) Program Maintenance Utility Version 9.00.21022.08
1>Copyright (C) Microsoft Corporation. All rights reserved.
1> "C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\nmake.exe" -f Makefile.Release all
1>Microsoft (R) Program Maintenance Utility Version 9.00.21022.08
1>Copyright (C) Microsoft Corporation. All rights reserved.
1> cl -c -nologo -Zm200 -Zc:wchar_t- -O2 -MD -GL -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"c:\Qt\4.5.0\include\QtCore" -I"c:\Qt\4.5.0\include\QtGui" -I"c:\Qt\4.5.0\include" -I"." -I"c:\Qt\4.5.0\include\ActiveQt" -I"release" -I"." -I"c:\Qt\4.5.0\mkspecs\win32-msvc2008" -Forelease\ @C:\DOCUME~1\1494\LOCALS~1\Temp\nm29.tmp
1>main.cpp
1>c:\Qt\4.5.0\include\QtCore/qconfig.h(1) : fatal error C1083: Cannot open include file: '../../src/corelib/global/qconfig.h': No such file or directory
1>NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\cl.EXE"' : return code '0x2'
1>Stop.
1>NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\nmake.exe"' : return code '0x2'
1>Stop.
1>Project : error PRJ0019: A tool returned an error code from "Performing Makefile project actions"
1>Build log was saved at "file://e:\Sankar\QT\Samples\HelloQt\HelloQt\Release\Build Log.htm"
1>HelloQt - 4 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
/************************************************** ****************************************/

Thanks & Regards,
Sankar.

tbscope
10th February 2011, 04:37
Do you have read/write access to those paths and files?

Edit: there is no need to restart this post the next day.

ChrisW67
10th February 2011, 06:17
Please use [code] tags around your code and code-like output... edit your post and repair it. This is the second time you have been asked.
Please do not start a new thread on the same topic every time you have another problem.

When you say:

2. Installed QT 4.5.0
How did you install it? Build it from source using your VS 2008 compiler? Why such an old version?

These are the basic steps:

Start a Visual C command prompt from the Windows Start menu OR start a standard command prompt and execute the Visual C setup script: http://msdn.microsoft.com/en-us/library/f2ccy3wt%28v=VS.90%29.aspx
Execute: SET PATH=C:\Qt\4.5.0\bin;%PATH%
Change directory to your project directory
Build it: qmake then nmake

Does this work?

sankar
11th February 2011, 03:06
tbscope:
Thanks.
Yes. I have read/write access to those paths and files.

Chris:
Thanks.
I have been doing the same, what you have asked me to try. But still i am facing the same error.

Error processing meta file: c:\Qt\4.5.0\lib\qtmain
Error processing meta file: c:\Qt\4.5.0\lib\qtmaind
Error processing meta file: c:\Qt\4.5.0\lib\qtmain


Regards,
Sankar.

ChrisW67
11th February 2011, 04:18
Can you answer the remainder of my queries?


How did you install it? Build it from source using your VS 2008 compiler? Why such an old version?

sankar
11th February 2011, 04:53
First installed VisualStudio2008 full version and then installed Qt 4.5.0 commercial version. I have been instructed to use this version olny.

Regards,
Sankar

ChrisW67
11th February 2011, 20:33
The error is emitted when qmake is trying to process the PRL files in your Qt lib directory. Does c:\Qt\4.5.0\lib\qtmain.prl exist? What does it contain?

Try running qmake with extra debug output:


qmake -d 2> debug.txt

to see if any useful diagnostic is output.

sankar
14th February 2011, 02:39
Yes, qtmain.prl file exist in the path "C:\Qt\4.5.0\lib\".

But I couldn't open the file. It says "Access to C:\Qt\4.5.0\lib\qtmain.prl is denied"

Ran "qmake -d 2> debug.txt" command and it produced debug.txt file which is attached here for your reference.

Regards,
Sankar.

ChrisW67
14th February 2011, 04:25
Yes, qtmain.prl file exist in the path "C:\Qt\4.5.0\lib\".

Good.


But I couldn't open the file. It says "Access to C:\Qt\4.5.0\lib\qtmain.prl is denied"

If you cannot read the file nor can qmake when you run it. Fix your permissions.

sankar
14th February 2011, 05:22
Thanks Chris.

It worked after fixing my permissions.

BTW, Could you please explain me the following build commands which will help me to understand it better

qmake -project => It creates a .pro file. ?

qmake => ?

Then how to create an exe from the hello.pro file?

If you can refer me some tutorial/link for the same will be very useful. Thanks again for sparing your valuable time.

Regards,
Sankar.

ChrisW67
14th February 2011, 06:57
qmake -project Will look at the source files in the directory and build a basic PRO file to make the project. In all but the simplest of program this PRO file will need to be changed, but for a simple "Hello, World!" it should be sufficient. You only need to make a PRO file once, and nothing stops you making one entirely manually.

qmakeTakes the project definition from the PRO file and builds a Makefile (or equivalent) for the environment that qmake finds itself in. Qmake has defaults for compiler, linker, paths etc. that were determined at the time qmake itself was built.

make (or equivalent) Build the project.

Open Assistant and read "Using qmake" and "qmake Tutorial" in the "QMake Manual"

sankar
18th February 2011, 09:48
Hi,
I am using the following command to build PRO & Make files and exe for WINDOWS environment,

qmake -project
qmake
nmake -release

How do we create the EXE for other platforms (LINUX, SOLARIS,..)

Thanks &Regards,
Sankar.

sankar
24th February 2011, 06:33
Could some one help me to fix this

Thanks &Regards,
Sankar.

FelixB
24th February 2011, 07:40
How do we create the EXE for other platforms (LINUX, SOLARIS,..)

compile your code on LINUX, and you get a LINUX executable.
compile your code on SOLARIS, and you get a SOLARIS executable.

AFAIK there is no way to create an executable for LINUX/... from a WINDOWS environment.

ChrisW67
24th February 2011, 23:27
It is possible to cross-compile on one platform for another. I suspect this is well beyond the OP's grasp of the situation though.

sankar
25th February 2011, 03:55
Thanks Chris.

So what do you suggest me to do now?

Regards,
Sankar.

ChrisW67
25th February 2011, 10:45
Follow FelixB's advice, build for each target system on the target system, unless you really want to build a complete cross-compiler suite for each target platform.

sankar
28th February 2011, 02:55
Ok Chris. I agree.

But, I need to build a complete cross-compiler suite for each platform (Atleast two platforms - Windows & Linux)

Regards,
Sankar.

ChrisW67
28th February 2011, 22:26
No. You already have a native build system on Windows (VS2008 and Qt).

The easiest way to build your code for a Linux target is to install Linux with GCC and Qt, copy your source code across, and build it on the Linux machine. You don't need another machine... you can use a virtual physical machine (VirtualBox or Vmware).

sankar
1st March 2011, 06:19
Thanks Chris for your detailed information.

Regards,
Sankar.