LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Difference between QT3 and QT4 when both are present (https://www.linuxquestions.org/questions/programming-9/difference-between-qt3-and-qt4-when-both-are-present-696209/)

navderm 01-09-2009 08:00 PM

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.

Sergei Steshenko 01-09-2009 08:14 PM

Quote:

Originally Posted by navderm (Post 3403073)
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.

navderm 01-09-2009 08:17 PM

So, If i could only remove and add the path in my .profile would that work??

map250r 01-09-2009 08:44 PM

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

ErV 01-09-2009 08:55 PM

Quote:

Originally Posted by navderm (Post 3403073)
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 (Post 3403073)
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 (Post 3403082)
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.

knudfl 01-09-2009 08:56 PM

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
....

map250r 01-09-2009 09:13 PM

Quote:

Originally Posted by knudfl (Post 3403105)
"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.

navderm 01-09-2009 09:15 PM

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

ErV 01-09-2009 10:39 PM

Quote:

Originally Posted by knudfl (Post 3403105)
"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.


All times are GMT -5. The time now is 02:43 PM.