RHEL 6.4 更改yum源,安装MySQL5.5与QT5.3.2

 参考:http://lanux.iteye.com/blog/1985626

updated 2015-03-18  

网易上CentOS6.5的yum源已失效,可以改用centos6.6的源,将“更改yum源”步骤中,

CentOS-Base.repo文件中的 6.5 改为 6.6 即可更新使用,如下示例的位置

baseurl=http://mirrors.163.com/centos/6.5/centosplus/$basearch/

updated 2014-11-23

一、 使用 CentOS 6.5 的 yum 源    

  1. 删除原有的yum源

    # rpm -aq | grep yum|xargs rpm -e --nodeps

  2.下载yum安装包,这里使用centos-6.5

    建议手动下载,地址:http://mirrors.163.com/centos/6.5/os/x86_64/Packages/

    python-iniparse-0.3.1-2.1.el6.noarch.rpm    

    yum-metadata-parser-1.1.2-16.el6.x86_64.rpm 

    yum-3.2.29-40.el6.centos.noarch.rpm

    yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm

  3.安装yum软件包

    # rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm     

    # rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm     

    # rpm -ivh yum-3.2.29-40.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm

  4. 更改yum源
 
    如果RPM-GPG-KEY-CentOS-6不存在则新建,下载地址:http://mirror.centos.org/centos/6.5/os/x86_64/RPM-GPG-KEY-CentOS-6
    在/etc/yum.repos.d/新建文件CentOS-Base.repo,内容如下:
 
# CentOS-Base.repo
#
# 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 - 163.com
baseurl=http://mirrors.163.com/centos/6.5/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#released updates 
[updates]
name=CentOS-$releasever - Updates - 163.com
baseurl=http://mirrors.163.com/centos/6.5/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 163.com
baseurl=http://mirrors.163.com/centos/6.5/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 163.com
baseurl=http://mirrors.163.com/centos/6.5/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - 163.com
baseurl=http://mirrors.163.com/centos/6.5/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

 

  5.清理yum缓存

    # yum clean all   

    # yum makecache #将服务器上的软件包信息缓存到本地,以提高搜索安装软件的速度   

    # yum install lrzsz #测试新源是否可用

 

updated  2014/11/25

 二、Qt5.3.2安装与配置  

  1,依赖软件:

         请具体阅读指出的README文件,并安装依赖软件包

           qt-everywhere-opensource-src-5.3.2/README

    使用yum安装xcb依赖:   

    #yum --enablerepo=updates install libxcb libxcb-devel xcb-util xcb-util-devel xcb-util-*-devel libX11-devel libXrender-devel

    Qt版本:qt-everywhere-opensource-src-5.3.2

    配置文件,~/.bashrc

    路径配置:#这个是我安装并配置Qt之后的完整的配置路径

      export PATH=/usr/local/qt-5.3.2/qtbase/bin:$PATH

      export MAKE=/usr/bin/make       

      export LD_LIBRARY_PATH=/usr/local/qt-5.3.2/qtbase/lib

   2、安装过程

    1,  安装yum,使用163上centos 6.5的源。

      可参考文章:http://www.cnblogs.com/shaw-me/articles/4117119.html

    2,  首先安装gcc,make,tar等工具,然后安装相应的依赖包。

    3,  由安装Qt之前需配置路径如下:

        export PATH=/usr/local/qt-5.3.2/qtbase/bin:$PATH #源码qt中qmake位置       

        export MAKE=/usr/bin/make #当不能识别make时,指定路径

    4,  安装过程:可以将命令写入脚本,使用重定向,记录log (install.sh>> install.log 2>&1 )

        cd <path>/qt-everywhere-opensource-src-<version>       

        ./configure -prefix $PWD/qtbase -opensource -nomake tests       

        make -j 4

    5,  安装Qt之后配置路径

      export PATH=/usr/local/qt-5.3.2/qtbase/bin:$PATH       

      export MAKE=/usr/bin/make       

      export LD_LIBRARY_PATH=/usr/local/qt-5.3.2/qtbase/lib

   3,使用说明

    1、  在当前源文件目录(test.cpp)使用命令,生成一个与平台无关的项目文件 test.pro

      qmake –project

    2、  从项目文件生成一个与平台相关的Makefile文件

      qmake test.pro

    3、  构建程序

      make

    注:生成的pro文件需要添加相应的组件

      test.cpp源码

      #include <QApplication>       

      #include <QLabel>       

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

        QApplication app(argc, argv);   

        QLabel *label = new QLabel("hello Qt");   

        label->show();   

        return app.exec();       

      }

 

    对应生成的hello.pro

        ######################################################################     

        # Automatically generated by qmake (3.0) Fri Nov 21 23:14:10 2014       

        ######################################################################     

        TEMPLATE = app     

        TARGET = test     

        INCLUDEPATH += .     

        # Input     

        SOURCES += test.cpp

    其中需要添加

      QT += core gui       

      greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    否则报错

    错误:

       # qmake

       bash: qmake: command not found

    解决:将已安装qt的bin目录加入环境变量$PATH中

    错误:

       This application failed to start because it could not find or load the Qt platform plugin "xcb".

       Available platform plugins are: linuxfb, minimal, offscreen.

        Reinstalling the application may fix this problem.

    解决:属于xcb依赖问题

    参考文章:

      Xcb问题   http://qt-project.org/wiki/Building-Qt-5-from-Git-SimplifiedChinese

      添加组件  http://bbs.csdn.net/topics/390658864?page=1

三、安装MySQL-server-5.5.40-1.el6.x86_64及编译QT5.3对应的驱动

  安装MySQL

    1,  由于RHEL6.4中已安装Mysql,使用命令查看已安装的信息

      # rpm -qa|grep mysql

      在卸载命令后加参数以不考虑dependencies,解决依赖问题

      # rpm -e mysql-server-5.0.77 –nodeps

    2,  安装软件包

      # rpm -ivh MySQL-server-5.5.40-1.el6.x86_64.rpm  #服务器

      # rpm -ivh MySQL-devel-5.5.40-1.el6.x86_64.rpm  #提供mysql的头文件和lib库

      # rpm -ivh MySQL-client-5.5.40-1.el6.x86_64.rpm  #客户端

    3,  查看是否已启动服务,否则启动

      # chkconfig mysqld on #查看服务是否启动

      # /etc/init.d/mysql start #启动服务,若已启动,就不用执行了

    4,  更改密码

      # /usr/bin/mysqladmin -u root password ‘NewPassWord’

    5,  自启动

      # /sbin/chkconfig mysql on

  编译QT5.3对应的驱动

    1,进入到源码包中mysql驱动工程文件目录下:

      #cd qt-5.3.2/qtbase/src/plugins/sqldrivers/mysql

一定不要使用 qmake -project 命令,因为mysql.pro文件已经指明了需要文件的路径

    2.生成makefile文件,为工程文件添加mysql的头文件和库文件

      #qmake "INCLUDEPATH+=/usr/include/mysql" "LIBS+=-L/usr/lib64/mysql -lmysqlclient_r" mysql.pro

     Ps:必须把include和lib64下的mysql文件夹包含进去,否则的话编译的时候会链接不到文件

       Ps:因为安装的RHEL为64位的,所以使用lib64

     3.开始编译直接 make编译完成后,会在qt-5.3.2/qtbase/plugins/sqldrivers目录下生成libqsqlmysql.so

   注:

    1,  编译若出现如下错误:

    [root@localhost mysql]# make

      rm -f libqsqlmysql.so

      g++ -Wl,--no-undefined -Wl,-O1 -Wl,-rpath,/usr/local/qt-5.3.2/qtbase/lib -shared -o libqsqlmysql.so .obj/main.o .obj/qsql_mysql.o .obj/

      moc_qsql_mysql_p.o -L/usr/lib64/mysql -lmysqlclient_r -L/usr/local/qt-5.3.2/qtbase/lib -lQt5Sql -lQt5Core -lpthread 

      /usr/lib64/mysql/libmysqlclient_r.a(client_plugin.c.o): In function `add_plugin':

      /pb2/build/sb_0-13157587-1410170252.03/rpm/BUILD/mysql-5.5.40/mysql-5.5.40/sql-common/client_plugin.c:178: undefined reference to `dlclose'

      /usr/lib64/mysql/libmysqlclient_r.a(client_plugin.c.o): In function `mysql_client_plugin_deinit':

      /pb2/build/sb_0-13157587-1410170252.03/rpm/BUILD/mysql-5.5.40/mysql-5.5.40/sql-common/client_plugin.c:280: undefined reference to `dlclose'

      /usr/lib64/mysql/libmysqlclient_r.a(client_plugin.c.o): In function `mysql_load_plugin_v':

      /pb2/build/sb_0-13157587-1410170252.03/rpm/BUILD/mysql-5.5.40/mysql-5.5.40/sql-common/client_plugin.c:354: undefined reference to `dlopen'

      /pb2/build/sb_0-13157587-1410170252.03/rpm/BUILD/mysql-5.5.40/mysql-5.5.40/sql-common/client_plugin.c:382: undefined reference to `dlsym'

      /pb2/build/sb_0-13157587-1410170252.03/rpm/BUILD/mysql-5.5.40/mysql-5.5.40/sql-common/client_plugin.c:374: undefined reference to `dlerror'

      /pb2/build/sb_0-13157587-1410170252.03/rpm/BUILD/mysql-5.5.40/mysql-5.5.40/sql-common/client_plugin.c:385: undefined reference to `dlclose'

      collect2: ld returned 1 exit status

      make: *** [../../../../plugins/sqldrivers/libqsqlmysql.so] Error 1

   解决:要对使用dlopen的文件进行编译时,需要加上-ldl,即静态链接glibc库。因为dlopen等函数属于glibc库

   使用如下命令:

     qmake "INCLUDEPATH+=/usr/include/mysql" "LIBS+=-L/usr/lib64/mysql -lmysqlclient_r -ldl" mysql.pro

  参考文章:

    Redhat企业版5.5下Mysql的安装与配置   http://bbs.phpchina.com/thread-202272-1-1.html

    mysql编译错误:undefined reference to `dlclose' Linux    http://blog.csdn.net/guowenyan001/article/details/9921199

    Fedora 17下编译Qt5的MySQL驱动   http://itlab.idcquan.com/linux/driver/921728.html

posted @ 2014-11-23 17:58  Madshaw  阅读(905)  评论(0编辑  收藏  举报