LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-19-2009, 01:21 PM   #1
BrajZore
Member
 
Registered: Sep 2007
Location: Växjö
Distribution: Slackware
Posts: 50

Rep: Reputation: 15
Qmake


Hi everyone!

I'm trying to learn QT and now I have a problem with qmake.

I create a project file with this command: qmake -project

My QT.pro looks like this:
Code:
######################################################################
# Automatically generated by qmake (1.07a) Wed Aug 19 21:33:54 2009
######################################################################

TEMPLATE = app
CONFIG += qt warn_on release 
INCLUDEPATH += .
TARGET = hello_world
SOURCES += hello_world.cpp
To get a makefile, i use this command: qmake -o Makefile QT.pro

When I type in make, this message appears:

Code:
g++ -c -pipe -Wall -W -O2  -DQT_NO_DEBUG -DQT_SHARED -DQT_THREAD_SUPPORT -I/usr/lib/qt/mkspecs/default -I. -I. -I/usr/lib/qt/include -o hello_world.o hello_world.cpp
hello_world.cpp:1:24: error: QApplication: No such file or directory
hello_world.cpp:2:18: error: QLabel: No such file or directory
hello_world.cpp: In function 'int main()':
hello_world.cpp:6: error: 'QApplication' was not declared in this scope
hello_world.cpp:6: error: expected `;' before 'a'
hello_world.cpp:8: error: 'QLabel' was not declared in this scope
hello_world.cpp:8: error: expected `;' before 'label'
hello_world.cpp:9: error: 'label' was not declared in this scope
hello_world.cpp:11: error: 'a' was not declared in this scope
make: *** [hello_world.o] Error 1
I don't know what the problem is. How can I compile and run the programs created in QT in a efficient way?
 
Old 08-19-2009, 01:27 PM   #2
orgcandman
Member
 
Registered: May 2002
Location: new hampshire
Distribution: Fedora, RHEL
Posts: 600

Rep: Reputation: 110Reputation: 110
Quote:
hello_world.cpp:1:24: error: QApplication: No such file or directory
hello_world.cpp:2:18: error: QLabel: No such file or directory
hello_world.cpp: In function 'int main()':
hello_world.cpp:6: error: 'QApplication' was not declared in this scope
hello_world.cpp:6: error: expected `;' before 'a'
hello_world.cpp:8: error: 'QLabel' was not declared in this scope
hello_world.cpp:8: error: expected `;' before 'label'
hello_world.cpp:9: error: 'label' was not declared in this scope
hello_world.cpp:11: error: 'a' was not declared in this scope
This indicates there could be a problem with your source. Can you post? Make sure to use code tags.
 
Old 08-19-2009, 02:03 PM   #3
BrajZore
Member
 
Registered: Sep 2007
Location: Växjö
Distribution: Slackware
Posts: 50

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by orgcandman View Post
This indicates there could be a problem with your source. Can you post? Make sure to use code tags.
hello_world.cpp
PHP Code:
#include <QApplication>
#include <QLabel>

int main()
{
    
QApplication a(argcargv);
    
    
QLabel label("Hello world");
    
label.show();
    
    return 
a.exec();

 
Old 08-19-2009, 03:02 PM   #4
xhypno
Member
 
Registered: Sep 2004
Posts: 62

Rep: Reputation: 16
Verify that your include path is correct.

your using /usr/lib/qt/include but it appears to not be finding the QT classes under it.
 
Old 08-19-2009, 08:43 PM   #5
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
The real name of the qt4 headers :
QtGui/QApplication and QtGui/QLabel
> >
#include <QtGui/QApplication>
#include <QtGui/QLabel>

The Qt4 headers are grouped in 19 directories :
//include/QtXxxx/<headers>

Ref. for qmake
http://doc.trolltech.com/3.0/qmake-guide.html
" qmake User's Guide "

The command 'qmake --help' is useful too.
.....

The file QT.pro can be very simple, ( 2 lines ) :
SOURCES = hello_world.cpp
TARGET = hello_world

'-Makefile' is default for qmake, so this will do
'qmake QT.pro'
to create the Makefile.
.....
 
Old 08-21-2009, 10:44 AM   #6
BrajZore
Member
 
Registered: Sep 2007
Location: Växjö
Distribution: Slackware
Posts: 50

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by xhypno View Post
Verify that your include path is correct.

your using /usr/lib/qt/include but it appears to not be finding the QT classes under it.
How can I verify it?

How can I do so the classes can be find?
 
Old 08-21-2009, 11:09 AM   #7
xhypno
Member
 
Registered: Sep 2004
Posts: 62

Rep: Reputation: 16
Quote:
Originally Posted by BrajZore View Post
How can I verify it?

How can I do so the classes can be find?
It depends on the os that you have installed. On Juanty with qt4 installed via apt the includes are here:

/usr/include/qt4/

Here is an update fixing issues with your cpp file (the input vars from the command line) and the compile output from my system.

Code:
#include <QApplication>
#include <QLabel>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    
    QLabel label("Hello world");
    label.show();
    
    return a.exec();
}
Code:
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o hello_world.o hello_world.cpp
g++ -Wl,-O1 -o hello_world hello_world.o    -L/usr/lib -lQtGui -lQtCore -lpthread
This compile works fine on my system. If your include paths and lib paths are still wrong you can set them with the following in your project file.

Code:
INCLUDEPATH += <dir>
LIBRARYPATH += <dir>
 
Old 08-26-2009, 01:51 AM   #8
BrajZore
Member
 
Registered: Sep 2007
Location: Växjö
Distribution: Slackware
Posts: 50

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by xhypno View Post
It depends on the os that you have installed. On Juanty with qt4 installed via apt the includes are here:

/usr/include/qt4/

Here is an update fixing issues with your cpp file (the input vars from the command line) and the compile output from my system.

Code:
#include <QApplication>
#include <QLabel>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    
    QLabel label("Hello world");
    label.show();
    
    return a.exec();
}
Code:
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o hello_world.o hello_world.cpp
g++ -Wl,-O1 -o hello_world hello_world.o    -L/usr/lib -lQtGui -lQtCore -lpthread
This compile works fine on my system. If your include paths and lib paths are still wrong you can set them with the following in your project file.

Code:
INCLUDEPATH += <dir>
LIBRARYPATH += <dir>
Hi!

It doesen't work. I still get the message:
Code:
hello_world.cpp:1:24: error: QApplication: No such file or directory
hello_world.cpp:2:18: error: QLabel: No such file or directory
hello_world.cpp: In function 'int main(int, char**)':
hello_world.cpp:6: error: 'QApplication' was not declared in this scope
hello_world.cpp:6: error: expected `;' before 'a'
hello_world.cpp:8: error: 'QLabel' was not declared in this scope
hello_world.cpp:8: error: expected `;' before 'label'
hello_world.cpp:9: error: 'label' was not declared in this scope
hello_world.cpp:11: error: 'a' was not declared in this scope
hello_world.cpp: At global scope:
hello_world.cpp:4: warning: unused parameter 'argc'
hello_world.cpp:4: warning: unused parameter 'argv'
How can I compile a application SIMPLE in QT? When I used Ubuntu, I compiled my application, by going to the menu. But that option doesen't exists QT on Slackware system. Why?
 
Old 08-26-2009, 04:31 AM   #9
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
I don't think that you are picking up the qt4 library, rather I suspect that you are picking up the code in the qt3 library. You may need to add this path to your $PATH variable.
 
Old 08-26-2009, 04:32 AM   #10
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Quote:
Originally Posted by BrajZore View Post
When I used Ubuntu, I compiled my application, by going to the menu. But that option doesen't exists QT on Slackware system. Why?
Have you installed the QT Creator? Just one IDE that you can use to easily compile Qt applications.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
qmake wrong with qt liuguobiao Programming 6 08-12-2009 09:29 PM
Suse 10.0 and qmake pevac SUSE / openSUSE 1 03-27-2006 02:45 AM
Where to get qmake for SuSE 10 KimVette SUSE / openSUSE 2 11-14-2005 10:03 AM
qmake Jongi SUSE / openSUSE 1 10-30-2005 02:05 AM
qt qmake nakkaya Programming 0 08-11-2003 07:42 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration