How to automatically connect qmake to Qt3 after qora5 is installed

Source: Internet
Author: User
When installing Qt4 on Fedora, I used the root user at the beginning, which is slightly different from Ubuntu. Export mvqt-everywhere-opensource-src-4.6.2.tar.gz/tmp # cd/examples # cd

When installing Qt4 on Fedora, I used the root user at the beginning, which is slightly different from Ubuntu.
# Music qt-everywhere-opensource-src-4.6.2.tar.gz/tmp
# Cd/tmp
# Gunzip qt-everywhere-opensource-src-4.6.2.tar.gz
# Tar xvf qt-everywhere-opensource-src-4.6.2.tar
# Cd qt-everywhere-opensource-src-4.6.2
#./Configure
# Gmake (note that gmake is used here)
# Gmake install
Environment variable settings are omitted.

After installing Qt4.6.2 on Fedora 5 according to the preceding steps, set the environment variable. www.linuxidc.com uses qmake to compile the program hello. cpp, the program code is as follows (the first program of C ++ GUI Programming With Qt 4 ):

# Include

# Include

Int main (int argc, char * argv [])

{

QApplication app (argc, argv );

QLabel * label = new QLabel ("Hello Qt! ");

Label-> show ();

Return app.exe c ();

}

$ Qmake-project

$ Qmake hello. pro

$ Make

Then an error occurs:

Hello. cpp: 1: 24: error: QApplication: No such file or directory
Hello. cpp: 2: 18: error: QLabel: No such file or directory
Hello. cpp: In function 'int main (int, char **)':
Hello. cpp: 6: error: 'qapplication' was not declared in this scope
Hello. cpp: 6: error: expected '; 'before' app'
Hello. cpp: 7: error: 'qlabel' was not declared in this scope
Hello. cpp: 7: error: 'label' was not declared in this scope
Hello. cpp: 7: error: expected type-specifier before 'qlabel'
Hello. cpp: 7: error: expected '; 'before' qlabel'
Hello. cpp: 9: error: 'app' was not declared in this scope
Hello. cpp: At global scope:
Hello. cpp: 4: warning: unused parameter 'argc'
Hello. cpp: 4: warning: unused parameter 'argv'
Make: *** [hello. o] Error 1

The analysis shows that the header file cannot be found, and all the following errors occur.

Therefore, we guess that the default qmake program in Qt3 is used.

Full-path compilation is as follows:

$/Usr/local/Trolltech/Qt-4.6.2/bin/qmake-project

$/Usr/local/Trolltech/Qt-4.6.2/bin/qmake hello. pro

$ Make

G ++-c-pipe-O2-Wall-W-D_REENTRANT-DQT_NO_DEBUG-DQT_GUI_LIB-DQT_CORE_LIB-DQT_SHARED-I/usr/local/Trolltech/Qt-4.6.2/mkspecs/linux-g + +-I. -I/usr/local/Trolltech/Qt-4.6.2/include/QtCore-I/usr/local/Trolltech/Qt-4.6.2/include/QtGui-I/usr/local/Trolltech/Qt-4.6.2/include -I. -I. -o hello. o hello. cpp
G ++-Wl,-O1-Wl,-rpath,/usr/local/Trolltech/Qt-4.6.2/lib-o hello. o-L/usr/local/Trolltech/Qt-4.6.2/lib-lQtGui-L/usr/local/Trolltech/Qt-4.6.2/lib-L/usr/X11R6/lib-lQtCore-lpthread

$ Ls

Hello. cpp hello. o hello. pro Makefile

The executable program hello, compiled successfully, run also successful, so concluded that the default qmake is not what we need/usr/local/Trolltech/Qt-4.6.2/bin/qmake.

The following describes how many qmake programs are available in the following system:
$ Locate qmake

/Usr/bin/qmake
/Usr/include/kdevelop/buildtools/parsers/qmake

/Usr/lib/qt-3.3/bin/qmake

// Usr/local/Trolltech/Qt-4.6.2/bin/qmake

Only list part of what we need. Well, we can see that there is a qt-3.3 of qmake among them, and/usr/bin in the environment variable, the first/usr/bin/qmake may be the error qmake. Let's take a look at/usr/bin/qmake:

$ Which qmake

/Usr/bin/qmake

We can see that this is the default qmake

$ Ls-l/usr/bin/qmake

Rwxrwxrwx 1 root 23 Mar 23/usr/bin/qmake-> ../lib/qt-3.3/bin/qmake

$ File/usr/bin/qmake
/Usr/bin/qmake: symbolic link to '../lib/qt-3.3/bin/qmake'

See, this is a soft link to qmake in the qt-3.3. You just need to modify the position it points.

$ Su

Password:

# Ln-s/usr/local/Trolltech/Qt-4.6.2/bin/qmake/usr/bin/qmake
Ln: creating symbolic link '/usr/bin/qmake' to '/usr/local/Trolltech/Qt-4.6.2/bin/qmake': File exists

# Ln-s/usr/local/Trolltech/Qt-4.6.2/bin/qmake/usr/bin/qmake1

# Ls/usr/bin/qmak *

/Usr/bin/qmake/usr/bin/qmake1

# Mv/usr/bin/qmake1/usr/bin/qmake
Mv: overwrite '/usr/bin/qmake '? Yes

# Ls/usr/bin/qmak *
/Usr/bin/qmake

# Ls-al/usr/bin/qmake
Lrwxrwxrwx 1 root 39 Mar 25/usr/bin/qmake->/usr/local/Trolltech/Qt-4.6.2/bin/qmake

Now, the Makefile is deleted and re-compiled:

$ Qmake-project
QFileInfo: absolutePath: Constructed with empty filename
$ Qmake hello. pro
$ Make
G ++-c-pipe-O2-Wall-W-D_REENTRANT-DQT_NO_DEBUG-DQT_GUI_LIB-DQT_CORE_LIB-DQT_SHARED-I/usr/local/Trolltech/Qt-4.6.2/mkspecs/linux-g + +-I. -I/usr/local/Trolltech/Qt-4.6.2/include/QtCore-I/usr/local/Trolltech/Qt-4.6.2/include/QtGui-I/usr/local/Trolltech/Qt-4.6.2/include -I. -I. -o hello. o hello. cpp
G ++-Wl,-O1-Wl,-rpath,/usr/local/Trolltech/Qt-4.6.2/lib-o hello. o-L/usr/local/Trolltech/Qt-4.6.2/lib-lQtGui-L/usr/local/Trolltech/Qt-4.6.2/lib-L/usr/X11R6/lib-lQtCore-lpthread
$ Ls
Hello. cpp hello. o hello. pro Makefile

Solve the problem.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.