rhel5国内已经不支持了,但是仍有人用,为匹配开发环境不得不用
为了安装Qt5,要先安装一些库,所以用到了yum,yum是付费功能,rhel5和centos5是一样的,所以用centos5的库安装
一.安装yum
a.清除之前的安装
rpm -aq|grep yum|xargs rpm -e --nodeps
b.下载安装四个包
从http://vault.centos.org/5.3/os/x86_64/CentOS/查找下面四个包,版本保证存在
python-iniparse-0.2.3-4.el5.noarch.rpm
yum-3.2.19-18.el5.centos.noarch.rpm
yum-fastestmirror-1.1.16-13.el5.centos.noarch.rpm
yum-metadata-parser-1.1.2-2.el5.x86_64.rpm
wget 之后rpm,rpm顺序
1.python
2.metadata
3.yum-3.2.19 fastestmirror
c.更新/etc/yum.repos,d/ 文件夹下的.repo文件
(下面有个更好的源,rpm -Uvh http://www.rpmfind.net/linux/sourceforge/d/ds/ds5752/yu/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpmrpmforge-release-0.5.2-2.el6.rf.x86_64.rpm)
内容为
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=http://vault.centos.org/5.11/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
baseurl=http://vault.centos.org/5.11/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
baseurl=http://vault.centos.org/5.11/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
baseurl=http://vault.centos.org/5.11/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
baseurl=http://vault.centos.org/5.11/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5</span></strong></span>
yum clean all
yum makecache
yum安装完成
二.安装qt5的准备-gnu
参照http://wiki.qt.io/How_to_Install_Qt_5_and_Qwt_on_CentOS_6,希望在低一个版本的rhel5也能安装
a.
sudo yum groupinstall "Development Tools"
出现问题
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID e8562897
GPG key retrieval failed: [Errno 5] OSError: [Errno 2] No such file or directory: '/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5'
解决方法:
参见:http://blog.chinaunix.net/uid-7573623-id-2048973.html和http://blog.itpub.net/11590946/viewspace-1068594/,
rpm -Uvh http://www.rpmfind.net/linux/sourceforge/d/ds/ds5752/yu/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpmrpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
之后连个不同的源repo
把/etc/yum.repos.d的repo的gpgcheck由1搞成0
b.
sudo yum install glibc-devel.i686
出自:https://www.cnblogs.com/tankblog/p/6096681.html
//结果不存在该程序,用
//yum install -y glibc.i686 glibc-common.i686 zlib.i686 libgcc.i686
可以了
c.安装gnu4.8.1,以支持c++11
wget http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-4.8.1/gcc-4.8.1.tar.bz2
tar xvjf gcc-4.8.1.tar.bz2
cd gcc-4.8.1
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
$PWD/../gcc-4.8.1/configure --prefix=$HOME/gcc-4.8.1
make
sudo make install
成功
d.Copy new GCC libraries to /usr/lib64
安装路径是在
--prefix=$HOME/gcc-4.8.1
因为是用的root用户,所以
sudo mv /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.bake //备份原来的连接,连接到了/user/lib64/libstdc++.so.6.0.8
sudo cp -P /root/gcc-4.8.1/lib64/libstdc++.so.6 /usr/lib64 //将新gnu的连接复制到/usr/lib64
sudo cp /root/gcc-4.8.1/lib64/libstdc.so.6.0.18 /usr/lib64/ //将新库考过区
sudo /sbin/ldconfig -v //??连接
e.两个版本切换
两个版本尽量独立
sudo rm -f /usr/lib64/libstdc++.so.6
sudo mv /usr/lib64/libstdc++.so.6.bake /usr/lib64/libstdc++.so.6
这样先把连接删除
因为which g++,which gcc发现g++ ,gcc都是/usr/bin/下的文件,所以备份
sudo mv /usr/bin/g++ /usr/bin/g++.bake
sudo mv /usr/bin/gcc /usr/bin/gcc.bake
建立软连接
ln -s /root/gcc-4.8.1/bin/g++ /usr/bin/g++
ln -s /root/gcc-4.8.1/bin/gcc /usr/bin/gcc
g++ -v ,gcc-v成功
三.安装qt5的准备-python
因为/lib64/libc.so.6的版本是2.5的,而安装程序是2.5以上的,所以不能运行.故需要编译运行
qt5需要perl5.8+python2.7,qt5.7之前gnu要c++98,qt5.7后要c++11
perl满足,而python要升级
a.
参见这里https://www.cnblogs.com/leon-zyl/p/8422699.html
从https://www.python.org/ftp/python/2.7.2/,用浏览器下载ssl不行,然后
tar -jxvf Python-2.7.2.tar.bz2
cd Python-2.7.2
mkdir /opt/py2.7 //避免覆盖旧版本,旧版本还有用
./configure --prefix=/opt/py2.7/
make
make install
mv /usr/bin/python /usr/bin/python.bake
ln -s /opt/py2.7/bin/python /usr/bin/python
python -V //2.7.2成功
//下面保证yum可以使用,xhost+是给root赋予gedit使用权
su sun
xhost +
gedit /usr/bin/yum ,将第一行的python改为python2.4,保证/usr/bin/python2.4存在奥
四.静态编译qt5.1.1
解压查看configure --help ,mkdir builddir,并在那里configure ,make ,make install
../qt-everywhere-opensource-src-5.6.3/configure -prefix /opt/qt5.6.3_gcc4.8.1 -release -confirm-license -opensource -c++std c++11 -static -qt-sql-sqlite -no-qml-debug -platform linux-g++-64 -qt-zlib -no-mtdev -no-journald -qt-libpng -qt-libjpeg -no-openssl -qt-pcre -qt-xcb -qt-xkbcommon-x11 -skip qtquickcontrols -skip qtquickcontrols2 -skip qtsensors -skip qtdoc -skip qt3d -no-compile-examples -no-opengl -no-avx
../qt-everywhere-opensource-src-5.6.3/configure -prefix /opt/qt5.6.3_gcc4.8.1 -release -confirm-license -opensource -c++std c++11 -static -qt-sql-sqlite -no-qml-debug -platform linux-g++-64 -qt-zlib -no-mtdev -no-journald -qt-libpng -qt-libjpeg -no-openssl -qt-pcre -qt-xcb -qt-xkbcommon-x11 -skip qtquickcontrols -skip qtquickcontrols2 -skip qtsensors -skip qtdoc -skip qt3d -no-compile-examples -no-opengl -no-avx
报错
The test for linking against libxcb failed!
You might need to install dependency packages for libxcb.
See src/plugins/platforms/xcb/README.
README:
Contains the header and sources files from selected xcb libraries:
libxcb-1.5 together with xcb-proto-1.6 (sync, xfixes, randr, xinerama sources)
# libxkbcommon-x11 requires libxcb-xkb >= 1.10
libxcb-1.10 together with xcb-proto-1.10 (xkb sources)
libxcb-util-image-0.3.9
libxcb-util-keysyms-0.3.9
libxcb-util-renderutil-0.3.8
libxcb-util-wm-0.3.9
The 'include' directory was obtained by compiling and installing all of the modules.
They have been tested to run also with libxcb 1.5 (the oldest version we support).
Use the -qt-xcb configure option to use the files instead of system xcb libraries.
See src/plugins/platforms/xcb/README for details.
所以装个xcb1.10吧
https://xcb.freedesktop.org/dist/
./configure报错:
configure: error: Package requirements (xcb-proto >= 1.10) were not met:
No package 'xcb-proto' found
安装xcb-proto,依旧报上面错误
安装pkg-config,点击打开链接
pkg-config --list-all
xcb-proto XCB Proto - X protocol descriptions for XCB
重新安装xcb,
checking for NEEDED... no
configure: error: Package requirements (pthread-stubs xau >= 0.99.2) were not met:
No package 'pthread-stubs' found
No package 'xau' found
尝试
yum install libXau-devel
yum有问题,自己下
http://vault.centos.org/5.3/os/x86_64/CentOS/
下载安装
[root@localhost xcb]# rpm -qi /usr/lib64/libXau.so.6
package /usr/lib64/libXau.so.6 is not installed
用readelf读到之前版本是1,但是可以看到之前的版本未安装,
先装pthread-stubs,https://xcb.freedesktop.org/dist/,0.3版本可以,现在就剩xau了
xproto.pc找不到,说是没有PKG_CONFIG_PATH,那么
sudo yum install mesa-libGL-devel
find /usr -name xproto.pc
得到路径/usr/lib64/pkgconfig/xproto.pc,
把/usr/lib64/pkgconfig/加入到/etc/profile最后,
export "PKG_CONFIG_PATH=/usr/lib64/pkgconfig"
source /etc/profile
env
发现PKG_CONFIG_PATH已经存在并生效,
进入xcb目录,./configure成功,make失败
xkb.c:5571:9: warning: nested extern declaration of 'uint8_t_sizeof' [-Wnested-externs]
make[2]: *** [xkb.lo] Error 1
make[2]: Leaving directory `/home/sun/qt/xcb/libxcb-1.10/src'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/sun/qt/xcb/libxcb-1.10/src'
make: *** [all-recursive] Error 1
改个xcb版本吧,改成11.1成功了
_______________________________________________________
进入qt-build目录,
../qt-everywhere-opensource-src-5.6.3/configure -prefix /opt/qt5.6.3_gcc4.8.1 -release -confirm-license -opensource -c++std c++11 -static -qt-sql-sqlite -no-qml-debug -platform linux-g++-64 -qt-zlib -no-mtdev -no-journald -qt-libpng -qt-libjpeg -no-openssl -qt-pcre -qt-xcb -qt-xkbcommon-x11 -skip qtquickcontrols -skip qtquickcontrols2 -skip qtsensors -skip qtdoc -skip qt3d -no-compile-examples -no-opengl -no-avx
成功.
make
报错
/usr/include/linux/futex.h:108:15: error: ‘u32’ was not declared in this scope
long do_futex(u32 *uaddr, int op, u32 val, unsigned long timeout,
^
/usr/include/linux/futex.h:108:20: error: ‘uaddr’ was not declared in this scope
long do_futex(u32 *uaddr, int op, u32 val, unsigned long timeout,
^
/usr/include/linux/futex.h:108:27: error: expected primary-expression before ‘int’
long do_futex(u32 *uaddr, int op, u32 val, unsigned long timeout,
^
/usr/include/linux/futex.h:108:35: error: ‘u32’ was not declared in this scope
long do_futex(u32 *uaddr, int op, u32 val, unsigned long timeout,
^
/usr/include/linux/futex.h:108:44: error: expected primary-expression before ‘unsigned’
long do_futex(u32 *uaddr, int op, u32 val, unsigned long timeout,
^
/usr/include/linux/futex.h:109:8: error: ‘u32’ was not declared in this scope
u32 *uaddr2, u32 val2, u32 val3);
^
/usr/include/linux/futex.h:109:13: error: ‘uaddr2’ was not declared in this scope
u32 *uaddr2, u32 val2, u32 val3);
^
/usr/include/linux/futex.h:109:21: error: ‘u32’ was not declared in this scope
u32 *uaddr2, u32 val2, u32 val3);
^
/usr/include/linux/futex.h:109:31: error: ‘u32’ was not declared in this scope
u32 *uaddr2, u32 val2, u32 val3);
^
/usr/include/linux/futex.h:109:39: error: expression list treated as compound expression in initializer [-fpermissive]
u32 *uaddr2, u32 val2, u32 val3);
^
/usr/include/linux/futex.h:112:20: error: ‘u32’ was not declared in this scope
handle_futex_death(u32 *uaddr, struct task_struct *curr, int pi);
^
/usr/include/linux/futex.h:112:25: error: ‘uaddr’ was not declared in this scope
handle_futex_death(u32 *uaddr, struct task_struct *curr, int pi);
^
/usr/include/linux/futex.h:112:32: error: expected primary-expression before ‘struct’
handle_futex_death(u32 *uaddr, struct task_struct *curr, int pi);
^
/usr/include/linux/futex.h:112:58: error: expected primary-expression before ‘int’
handle_futex_death(u32 *uaddr, struct task_struct *curr, int pi);
^
/usr/include/linux/futex.h:112:64: error: expression list treated as compound expression in initializer [-fpermissive]
handle_futex_death(u32 *uaddr, struct task_struct *curr, int pi);
^
make[3]: *** [.obj/qmutex.o] Error 1
make[3]: Leaving directory `/home/sun/qt/qt-build/qtbase/src/corelib'
make[2]: *** [sub-corelib-make_first] Error 2
make[2]: Leaving directory `/home/sun/qt/qt-build/qtbase/src'
make[1]: *** [sub-src-make_first] Error 2
make[1]: Leaving directory `/home/sun/qt/qt-build/qtbase'
make: *** [module-qtbase-make_first] Error 2
把-c++std c++11 改为-c++std c++98试试,报相同错误
把g++ 和gcc改回原版本看看
[root@localhost bin]# rm -f /usr/bin/g++
[root@localhost bin]# rm -f /usr/bin/gcc
[root@localhost bin]# mv /usr/bin/g++.bake /usr/bin/g++
[root@localhost bin]# mv /usr/bin/gcc.bake /usr/bin/gcc
还是报相同错误,换个qt版本试试吧,换成qt5.1.1
configure选项
../qt-everywhere-opensource-src-5.1.1/configure -prefix /opt/qt5.1.1_gcc4.1.1 -release -confirm-license -opensource -no-c++11 -static -qt-sql-sqlite -no-qml-debug -platform linux-g++-64 -qt-zlib -qt-libpng -qt-libjpeg -no-openssl -qt-pcre -qt-xcb -qt-xkbcommon -skip qtquickcontrols -skip qtsensors -skip qtdoc -no-compile-examples -no-opengl -no-avx -skip qtwebkit
cp /usr/include/linux/futex.h /usr/include/linux/futex.h.bake
gedit /usr/include/linux/futex.h
在108行前添加
#define u32 unsigned int
报错
warning: converting to ‘quint64’ from ‘double’
make[3]: *** [.obj/release-static/qbenchmarkperfevents.o] Error 1
make[3]: Leaving directory `/home/sun/qt/qt-build/qtbase/src/testlib'
make[2]: *** [sub-testlib-make_first] Error 2
make[2]: Leaving directory `/home/sun/qt/qt-build/qtbase/src'
make[1]: *** [sub-src-make_first] Error 2
make[1]: Leaving directory `/home/sun/qt/qt-build/qtbase'
make: *** [module-qtbase-make_first] Error 2
还是重新用gcc4.8.1qt5.6.3,make报错
In file included from /usr/include/asm-x86_64/byteorder.h:30:0,
from /usr/include/asm/byteorder.h:5,
from /home/sun/qt/qt-everywhere-opensource-src-5.6.3/qtbase/src/testlib/3rdparty/linux_perf_event_p.h:19,
from /home/sun/qt/qt-everywhere-opensource-src-5.6.3/qtbase/src/testlib/qbenchmarkperfevents.cpp:53:
/usr/include/linux/byteorder/little_endian.h:43:19: error: ‘__le64’ does not name a type
static __inline__ __le64 __cpu_to_le64p(const __u64 *p)
^
/usr/include/linux/byteorder/little_endian.h:47:46: error: ‘__le64’ does not name a type
static __inline__ __u64 __le64_to_cpup(const __le64 *p)
^
/usr/include/linux/byteorder/little_endian.h:67:19: error: ‘__be64’ does not name a type
static __inline__ __be64 __cpu_to_be64p(const __u64 *p)
^
/usr/include/linux/byteorder/little_endian.h:71:46: error: ‘__be64’ does not name a type
static __inline__ __u64 __be64_to_cpup(const __be64 *p)
^
In file included from /usr/include/sys/syscall.h:32:0,
from /home/sun/qt/qt-everywhere-opensource-src-5.6.3/qtbase/src/testlib/qbenchmarkperfevents.cpp:50:
/home/sun/qt/qt-everywhere-opensource-src-5.6.3/qtbase/src/testlib/qbenchmarkperfevents.cpp: In function ‘int perf_event_open(perf_event_attr*, pid_t, int, int, long unsigned int)’:
/home/sun/qt/qt-everywhere-opensource-src-5.6.3/qtbase/src/testlib/qbenchmarkperfevents.cpp:126:20: error: ‘__NR_perf_event_open’ was not declared in this scope
return syscall(SYS_perf_event_open, attr, pid, cpu, group_fd, flags);
^
/home/sun/qt/qt-everywhere-opensource-src-5.6.3/qtbase/src/testlib/qbenchmarkperfevents.cpp:136:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
make[3]: *** [.obj/qbenchmarkperfevents.o] Error 1
make[3]: Leaving directory `/home/sun/qt/qt-build/qtbase/src/testlib'
make[2]: *** [sub-testlib-make_first] Error 2
make[2]: Leaving directory `/home/sun/qt/qt-build/qtbase/src'
make[1]: *** [sub-src-make_first] Error 2
make[1]: Leaving directory `/home/sun/qt/qt-build/qtbase'
make: *** [module-qtbase-make_first] Error 2
make时使用make -k 当发生错误时,尽可能继续编译,参见Linux下快速静态编译Qt以及Qt动态/静态版本共存
_________________________________________________________________________________________
更新,放弃5吧,用了官方的方法,写个脚本,
https://blog.csdn.net/z3512498/article/details/64922180
http://wiki.qt.io/Deploying_a_Qt5_Application_Linux
能在同一个系统版本下运行了,但不能在红帽运行,结合patchelf也不行,fatal:kernel too old,百度redhat5安装qt就知道了,qt4是可以的
1.把gnu改回4.1.1
2.下载qt-creator2.0是个bin文件,可以安装的
3.静态编译qt4.7.0,
configure选项...
../qt-everywhere-opensource-src-4.7.0/configure -prefix /opt/qt4.7.0_gcc4.1.1 -release -opensource -static -no-fast -no-largefile -exceptions -accessibility -stl -qt-sql-sqlite -plugin-sql-sqlite -qt3support -xmlpatterns -no-multimedia -no-audio-backend -no-svg -no-webkit -no-mmx -no-3dnow -no-sse -no-sse2 -no-gif -no-libtiff -qt-libpng -no-libmng -qt-libjpeg -nomake examples -nomake tests
gmake
gmake install
4.生成的程序在原装红帽中可以运行,好了,改qt5的程序为qt4吧