LinuxQuestions.org
Help answer threads with 0 replies.
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 01-09-2009, 08:00 PM   #1
navderm
Member
 
Registered: Dec 2008
Location: Chandigarh, India
Distribution: Red Hat 9
Posts: 67

Rep: Reputation: 15
Difference between QT3 and QT4 when both are present


How would a compiler get to know whether the project that I am compiling is to be compiled with QT3 or QT4?

Please explain as I have to install QT4 and I don't want to do that till I am sure this is not going to ruin my system and the program that I have made.
 
Old 01-09-2009, 08:14 PM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by navderm View Post
How would a compiler get to know whether the project that I am compiling is to be compiled with QT3 or QT4?

Please explain as I have to install QT4 and I don't want to do that till I am sure this is not going to ruin my system and the program that I have made.
Do you think your question is Qt-specific ? I think not.

If I am correct, you have to learn how to specify include directories for compiler and library search path for linker.
 
Old 01-09-2009, 08:17 PM   #3
navderm
Member
 
Registered: Dec 2008
Location: Chandigarh, India
Distribution: Red Hat 9
Posts: 67

Original Poster
Rep: Reputation: 15
So, If i could only remove and add the path in my .profile would that work??
 
Old 01-09-2009, 08:44 PM   #4
map250r
Member
 
Registered: Aug 2007
Distribution: Debian Squeeze
Posts: 46

Rep: Reputation: 15
You will probably have to use qmake to compile your program, due to the meta objects. qt4 .pro files are not compatible with the qt3 version of qmake.

On my system (Debian):
$ qmake <tab><tab>
qmake qmake-qt3 qmake-qt4
$ type qmake
qmake is /usr/bin/qmake
$ ls -l /usr/bin/qmake
lrwxrwxrwx 1 root root 23 2006-03-10 20:57 /usr/bin/qmake -> /etc/alternatives/qmake
$ ls -l /etc/alternatives/qmake
lrwxrwxrwx 1 root root 18 2008-12-27 01:22 /etc/alternatives/qmake -> /usr/bin/qmake-qt4

So you either need to make sure the symlink(s) point to the correct qmake, or remember to type qmake-qt4 each time. Otherwise you'll get a bunch of errors.

On your distribution, if qt3 and qt4 packages aren't compatible, the maintainer has probably configured them to conflict with each other.
If you don't have the qt3 development stuff installed, it's probably a non-issue.

HTH
map250r
 
Old 01-09-2009, 08:55 PM   #5
ErV
Senior Member
 
Registered: Mar 2007
Location: Russia
Distribution: Slackware 12.2
Posts: 1,202
Blog Entries: 3

Rep: Reputation: 62
Quote:
Originally Posted by navderm View Post
How would a compiler get to know whether the project that I am compiling is to be compiled with QT3 or QT4?
Have you built any Qt applications? Are you familiar with Qt build system? If not, read some tutorials/docs on doc.trolltech.com.
You'll be using different qmake version for qt3 and qt4 projects. Generated Qt3 and Qt4 binaries will use different libraries.

Quote:
Originally Posted by navderm View Post
Please explain as I have to install QT4 and I don't want to do that till I am sure this is not going to ruin my system and the program that I have made.
Normally, Qt 3 and Qt 4 don't conflict with each other. This is because default compilation of Qt 4 puts all file in /usr/local/Trolltech/Qt-*/ folder, so there is little chance of overwriting anything from Qt 3.

Quote:
Originally Posted by Sergei Steshenko View Post
Do you think your question is Qt-specific ? I think not.
It is Qt-specific because of non-standard build system.
Qt projects are created from *.pro file. In order to generate makefile, *.pro file is fed to qmake. Qmake defines which set of libraries is used. Use qmake from Qt 4, and makefile will link your program with Qt 4 libraries, use it With Qt 3 - and you'll get Qt 3 libraries. In reality, of course, Qt 4 make probably won't "understand" Qt 3 *.pro file (makefile generation will fail) and vice versa.

Last edited by ErV; 01-09-2009 at 08:57 PM.
 
Old 01-09-2009, 08:56 PM   #6
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
Most Linux have both Qt3 and Qt4 these days.
You get /usr/lib/qt3/ and /usr/lib/qt4 .

And /usr/bin/qmake , /usr/bin/qmake-qt4 .

If required, please install Qt4 with your
package manager.

"Projects" usually end up with a 'Makefile',
selecting the right qt.
....
EDIT : sorry, too simplistic, see # 4 - # 5
....

Last edited by knudfl; 01-10-2009 at 06:21 AM.
 
Old 01-09-2009, 09:13 PM   #7
map250r
Member
 
Registered: Aug 2007
Distribution: Debian Squeeze
Posts: 46

Rep: Reputation: 15
Quote:
Originally Posted by knudfl View Post
"Projects" usually end up with a 'Makefile',
selecting the right qt.
I disagree here. The makefile is generated by qmake, so it's necessary for the user to run the correct version of qmake.
 
Old 01-09-2009, 09:15 PM   #8
navderm
Member
 
Registered: Dec 2008
Location: Chandigarh, India
Distribution: Red Hat 9
Posts: 67

Original Poster
Rep: Reputation: 15
Thank you guyz for such good help.

Finally,
I had made a code with QT3 in mind. So can i safely install QT4 and start running in the code without much hassle.

Actually I wanted to use cross thread signal slot systems which i learnt was not supported in QT3 (after reaching a level where my project was to end in next 2 days). So I am apprehensive that working with QT4 will create havoc coz I read some posts of people complaining a lot of changes.

If also there is a way by which we can use cross thread signal slot without changing to QT4 (its the last phase of my project...). Help would be appreciated.

And if there is really no problem with running a code written for QT3 in QT4 then i could change it ... would be good with me...

Thank you so much guyz
 
Old 01-09-2009, 10:39 PM   #9
ErV
Senior Member
 
Registered: Mar 2007
Location: Russia
Distribution: Slackware 12.2
Posts: 1,202
Blog Entries: 3

Rep: Reputation: 62
Thumbs down

Quote:
Originally Posted by knudfl View Post
"Projects" usually end up with a 'Makefile',
selecting the right qt.
....
No. Read documentation.
You create *.pro file, THEN generate makefile from it, and THEN compile project using that makefile. You can get away with normal makefiles ONLY if you aren't creating your own objects with signals and slots, because header of any Q_OBJECT class must be processed with moc to become compileable/useful.
 
  


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
QT4 and QT3.3 spaceballs Slackware 7 04-28-2008 08:18 AM
Upgrade qt3 -> qt4. Symlinks still point to qt3 alar Linux - Software 1 06-07-2007 09:45 PM
how to upgrade from qt3 to qt4 in fc3? dr_zayus69 Linux - Software 1 07-05-2006 01:52 AM
qt3 together with qt4 marekjs Slackware 2 06-28-2006 07:16 AM
qt3 or qt4 crAckZ Programming 1 09-06-2005 05:08 PM

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

All times are GMT -5. The time now is 01:15 PM.

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