CenOS with CutyCapt

CenOS with CutyCapt

一 安裝QT44

二 把安裝QT44目錄寫到環境參數中

三 下載軟體編譯安裝

四 安裝x-server

五 Dbug

安裝QT44解碼器居然有三種方法

1. rmp包安裝

2. 增加源安裝

3. Centos 6.X 直接yum安裝更新版確實方便

rpm 安裝

安裝 QT44 解碼器
(x86)
wget http://ftp.riken.go.jp/Linux/atrpms/el5-i386/atrpms/testing/qt44-4.4.3-10_4.el5.i386.rpm
wget http://ftp.riken.go.jp/Linux/atrpms/el5-i386/atrpms/testing/qt44-x11-4.4.3-10_4.el5.i386.rpm
wget http://ftp.riken.go.jp/Linux/atrpms/el5-i386/atrpms/testing/qt44-devel-4.4.3-10_4.el5.i386.rpm

(x64)
wget http://dl.atrpms.net/el5-x86_64/atrpms/testing/qt44-4.4.3-10_4.el5.x86_64.rpm
wget http://dl.atrpms.net/el5-x86_64/atrpms/testing/qt44-x11-4.4.3-10_4.el5.x86_64.rpm
wget http://dl.atrpms.net/el5-x86_64/atrpms/testing/qt44-devel-4.4.3-10_4.el5.x86_64.rpm

rpm -ivh qt44-4.4.3-10*
rpm -ivh qt44-x11-4.4.3-10*
rpm -e qt-devel –nodeps –allmatches
rpm -ivh qt44-devel-4.4.3-10*
rpm -rebuilddb

這一步如果不成功的話應該是各種依賴的問題

可以安裝 qt-devel 依賴包
yum install libXi-devel
yum install libXinerama-devel

也許這裏還會有報錯提示

warning: qt44-x11-4.4.3-10_4.el5.x86_64.rpm: Header V4 DSA signature: NOKEY, key ID 66534c2b
error: Failed dependencies:
libGLU.so.1()(64bit) is needed by qt44-x11-4.4.3-10_4.el5.x86_64
libmng.so.1()(64bit) is needed by qt44-x11-4.4.3-10_4.el5.x86_64

執行代碼:

yum -y install qt-devel*

提示依賴什麼就裝什麼。

可以用 yum search packName 來找有沒有這個包

如:yum search qt-devel

如果結果結果有包,那麼安裝時上執行 yum -y install qt-devel* 安裝,加*號是為了安裝上它所有的依賴包

增加源安裝

CentOS 5.x 安裝教程如下:

Add this to /etc/yum.repos.d/CentOS-Base.repo
#ATrpms
[atrpms]
name= CentOS-$releasever – ATrpms
baseurl=http://dl.atrpms.net/el$releasever-$basearch/atrpms/testing
gpgcheck=1
gpgkey=http://ATrpms.net/RPM-GPG-KEY.atrpms
enabled=1

rpm –import http://packages.atrpms.net/RPM-GPG-KEY.atrpms
yum install subversion qt47-devel qt47-webkit gcc-c++ qt47-webkit-devel sqlite
centos 6.x安裝

安裝gc-c++

yum install gcc-c++

安裝Qt依懶

yum install qt

yum install qt-devel

安裝的目錄在:

/usr/lib64/qt4

qmake 可以用 /usr/lib64/qt4/bin/qmake 執行

環境變數配置

加入 QT 目錄到環境參數中 如果是32位元系統刪除下面紅字的64
vim /etc/profile
#==================================================
export QTDIR=/usr/lib64/qt44
export QTLIB=/usr/lib64/qt44/lib
export QTINC=/usr/lib64/qt44/include
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
export PATH=$QTDIR/bin:$PATH
#==================================================

保存退出後,運行一次該檔

source /etc/profile

編譯程序

% svn co https://cutycapt.svn.sourceforge.net/svnroot/cutycapt (沒有svn的yum install subversion)h
% cd cutycapt/CutyCapt
% qmake
% make

如果沒有X server的話需要使用xvfb-run:

wget http://www.flexthinker.com/wp-content/uploads/2009/11/xvfb-run.sh.txt

mv ./xvfb-run.sh.txt ./xvfb-run.sh

chmod u+x ./xvfb-run.sh

./xvfb-run.sh –server-args=”-screen 0, 1024x768x24″ /home/xxx/cutycapt/CutyCapt/CutyCapt –url=http://www.163.com –out=163.jpg
dbug

qmake

make

出現以下錯誤

/usr/lib64/qt47/libQtWebKit.so: undefined reference to `sqlite3_prepare16_v2′

/usr/lib64/qt47/libQtWebKit.so: undefined reference to `sqlite3_column_value’

collect2: ld returned 1 exit status

make: *** [CutyCapt] Error 1

解決:

yum update sqlite

再次執行

make

如果還不成功

qmake-qt47
再次執行make

以下表示make成功

[root@localhost CutyCapt]# make

g++ -Wl,-O1 -o CutyCapt CutyCapt.o moc_CutyCapt.o -L/usr/lib64/qt47 -lQtWebKit -lQtSvg -L/usr/lib64/qt47 -lQtGui -lQtNetwork -lQtCore -lpthread

執行

xvfb-run –server-args=”-screen 0, 1024x768x24″ ./CutyCapt –url=http://www.baidu.com/ –out=localfile1.png –body-string=utf-8

出現-bash: xvfb-run: command not found

安裝

yum install Xorg Xvfb xauth xorg-x11-fonts*

不知道為什麼安裝後 沒有自動生成xvfb-run

下載並上傳xvfb-run腳本到

/usr/bin

chmod +x xvfb-run

運行 ../../xvfb-run.sh ./CutyCapt –url=http://www.baidu.com/ –out=localfile1.png –body-string=utf-8

Locking assertion failure. Backtrace:

#0 /usr/lib/libxcb-xlib.so.0 [0x114737]

#1 /usr/lib/libxcb-xlib.so.0(xcb_xlib_unlock+0x31) [0x114891]

#2 /usr/lib/libX11.so.6 [0xc1d021]

#3 /usr/lib/libXfixes.so.3(XFixesQueryVersion+0x4b) [0x2ddebb]

#4 /usr/lib/qt47/libQtGui.so.4 [0x4f5ad20]

#5 /usr/lib/qt47/libQtGui.so.4(_ZN19QApplicationPrivate9constructEP9_XDisplaymm+0xdf) [0x4ecf15f]

#6 /usr/lib/qt47/libQtGui.so.4(_ZN12QApplicationC1ERiPPcbi+0x8b) [0x4ecfd7b]

#7 ./CutyCapt(_ZN8QWebPage13triggerActionENS_9WebActionEb+0x1838) [0x804bcdc]

#8 /lib/libc.so.6(__libc_start_main+0xdc) [0x326e9c]

#9 ./CutyCapt(_ZN7QObject5eventEP6QEvent+0x15d) [0x804ac21]

CutyCapt: xcb_xlib.c:82: xcb_xlib_unlock: Assertion `c->xlib.lock’ failed.

../../xvfb-run.sh: line 168: 12780 Aborted DISPLAY=:$SERVERNUM XAUTHORITY=$AUTHFILE “$@” 2>&1

BUG描述:
運行用Swing的APP時,會無法啟動,顯示類似於”Assertion `c->xlib.lock’ failed.”的
問題
如Zend Studio和NetBeans無法正常啟動,官方解釋這是由於使用了XCB而不是LibX的緣故
,關鍵就在於assert時,Lock問題。一種解決方案是回去使用libx,另一種則是去掉asse
rt時的檢查。

下面的解決方案可行,(試過。)

[轉]
=======================================
Here’s one explaination:

Re: NB doesn’t work in open suse 10.3 “Assertion `c->xlib.lock’ failed.”
Click to flag this post

by pujansrt Oct 11, 2007; 02:45pm :: Rate this Message: – Use ratings to moder
ate (?)

Reply | Reply to Author | View Threaded | Show Only this Message
This is the solution–> just add this to your Environment
export LIBXCB_ALLOW_SLOPPY_LOCK=1

========================================

也就是運行程式前先運行

export LIBXCB_ALLOW_SLOPPY_LOCK=1

再次運行

xvfb-run –server-args=”-screen 0, 1024x768x24″ ./CutyCapt –url=http://www.baidu.com/ –out=localfile1.png –body-string=utf-8

等一會見到生成了localfile1.png表示成功了

不過每次都輸入

export LIBXCB_ALLOW_SLOPPY_LOCK=1 有點麻煩

大神給了個解決方法

cat > run

vi run

輸入

export LIBXCB_ALLOW_SLOPPY_LOCK=1

../../xvfb-run.sh ./CutyCapt –url=$1 –out=$2 –body-string=$3

保存退出

chmod +x ./run

./run http://www.baidu.com test.jpg, utf-8

依次輸入 $1 http://www.baidu.com $2 圖片名 $3字體

截圖成功

如果中文不能正常顯示的話,需要安裝字體檔

yum install fo nts-chinese

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *