QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 2980|回复: 1

安装Qt4及编程环境设置

[复制链接]
发表于 2008-1-30 17:16:05 | 显示全部楼层 |阅读模式
一、编译安装:

./configure  --release -plugin-sql-mysql -plugin-sql-sqlite -plugin-sql-odbc -plugin-sql-psql

但是在运行的时候,它会可能会提示你测试不到mysql或pgsql函数
于是,要增加/etc/profile环境

LD_LIBRARY_PATH=/usr/local/pgsql/lib:/usr/local/mysql/lib/mysql

要修改一下configure后Qt4源码的src/plugins/sqldrivers/mysql/mysql.pro在最开始处,加上下面两行(具体的目录,需要你自己查看系统的实际位置

INCLUDEPATH += /usr/local/mysql/include/mysql
LIBS += -L/usr/local/mysql/lib/mysql

pgsql则类似以上修改src/plugins/sqldrivers/mysql/mysql.pro

INCLUDEPATH+=/usr/local/pgsql/include /usr/local/pgsql/include/server /usr/local/pgsql/include/internal
LIBS += -L/usr/local/pgsql/lib

如果数据库如本教程是安装在/usr下,那么应该是这样:

INCLUDEPATH+=/usr/include/postgresql/server /usr/include/postgresql/internal /usr/include/postgresql/informix
LIBS += -L/usr/lib/postgresql

然后运行
./configure  --release -plugin-sql-mysql -plugin-sql-sqlite -plugin-sql-odbc -plugin-sql-psql -continue
make
make install

可能发现插件仍未被安装,进入src/plugins/sqldrivers/mysql,进行make;make install,其它数据库插件类似。

在编译QT的时候,如果在 ./configure的时候没有加任何参数的话,QT4默认编译release和debug两个版本,因此编译时间特别长,./configure 上加上 --release 参数. 这样只编译一份release的,可以省下一半以上的时间。

二、编程环境的设置:

编译安装非常费时,可以直接安装现成的rpm包,everest工具盘有提供,也可以到以下地址下载安装包

ftp://linux-ren.org/uploads/haulm/Qt-4.2


为了避免主用户(经常编译程序的用户)在编译软件时遇到使用的Qt3.x和Qt4学习环境相混淆,最好是新建一个专门的用户来学习Qt4编程。

新建用户并登录,然后需要在我们的shell配置文件里增加几行,bash配置文件为.bash_profile:

执行kwrite ~/.bash_profile

添加如下内容:

PATH=/usr/lib/qt4/bin:$PATH
export PATH
QTDIR=/usr/lib/qt4/
export QTDIR

执行以下命令:

cd /usr/bin

ln -s /usr/lib/qt4/bin/qmake qmake4

ln -s /usr/lib/qt4/bin/designer designer4

ln -s /usr/lib/qt4/bin/assistant assistant4

运行/usr/lib/qt4/bin/qtconfig,在Font项将字体设置为更好的字体,比如设置为Bitstream  Charter退出
 楼主| 发表于 2008-3-11 21:08:35 | 显示全部楼层
编译Qt4 例程的方法:

新建目录,存入源码文件,运行

qmake4 -project
qmake4
make
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-3-29 22:14 , Processed in 0.122110 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表