CentOS6 with CutyCapt

CentOS6 with CutyCapt

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

[atrpms-testing]
name=CentOS $releasever – $basearch – ATrpms testing
baseurl=http://dl.atrpms.net/el$releasever-$basearch/atrpms/testing
gpgkey=http://ATrpms.net/RPM-GPG-KEY.atrpms
gpgcheck=1
enabled=1

yum install qt47 qt47-devel qt47-webkit qt47-webkit-devel
yum -y install subversion
yum -y install gcc+ gcc-c++
svn co https://cutycapt.svn.sourceforge.net/svnroot/cutycapt
vi /etc/profile
export QTDIR=/usr/lib64/qt47
export QTLIB=/usr/lib64/qt47/lib
export QTINC=/usr/lib64/qt47/include
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
export PATH=$QTDIR/bin:$PATH

mv cutycapt/CutyCapt /usr/local/cutycapt
cd /usr/local/cutycapt
qmake
make

wget http://www.flexthinker.com/wp-content/uploads/2009/11/xvfb-run.sh.txt
mv ./xvfb-run.sh.txt /usr/local/cutycapt/xvfb-run.sh
chmod u+x /usr/local/cutycapt/xvfb-run.sh
yum install xorg-x11-server-Xvfb
yum install cjkuni-ukai-fonts cjkuni-uming-fonts -y

CentOS 安裝cutycapt 二

CentOS 安裝cutycapt 二

CutyCapt作爲IECapt的兄弟,可以跨平臺運行,生成的文件格式也多,SVG、PDF、 PS、 PNG、 JPEG,、TIFF,、GIF和BMP,CutyCap依賴于Qt。
一,先安裝Qt47
增加qt47的下載源
vi /etc/yum.repos.d/atrpms.repo
[atrpms]
name=CentOS $releasever – $basearch – ATrpms
baseurl=http://dl.atrpms.net/el$releasever-$basearch/atrpms/stable
gpgkey=http://ATrpms.net/RPM-GPG-KEY.atrpms
gpgcheck=1
enabled=1

[atrpms-testing]
name=CentOS $releasever – $basearch – ATrpms testing
baseurl=http://dl.atrpms.net/el$releasever-$basearch/atrpms/testing
gpgkey=http://ATrpms.net/RPM-GPG-KEY.atrpms
gpgcheck=1
enabled=1
#yum update
yum install qt47
yum install qt47-devel
yum install qt47-webkit
yum install qt47-webkit-devel
可能的錯誤:
warning: qt44-x11-4.4.3-10_4.el5.x86_64.rpm: Header V4 DSA signature: NOKEY, key ID 66534c2b
解决:
yum -y installqt-devel*
可能的錯誤:某些衝突conflict
qt47-x11 conflicts with qt-x11
qt47-x11 conflicts with qt-x11
解决:通過yum remove 卸載衝突的內容
yum remove qt-devel
yum remove qt-x11
二,安裝 CutyCapt
下載代碼,這裏需要用到SVN,如果沒有安裝,可以使用命令安裝:
#yum install subversion
svn co https://cutycapt.svn.sourceforge.net/svnroot/cutycapt
mv cutycapt/CutyCapt /usr/local/cutycapt
cd /usr/local/cutycapt
qmake
可能會出現的錯誤:
-bash: qmake: command not found
解决:
qmake-qt47
make
此處可能會報錯:
make: *** [CutyCapt] Error 1
解决:
yum update sqlite #如果是6.0,默認就是3.6
再次執行make即可!
三、下載和安裝X-Server
wget http://www.flexthinker.com/wp-content/uploads/2009/11/xvfb-run.sh.txt
mv ./xvfb-run.sh.txt /usr/local/cutycapt/xvfb-run.sh
chmod u+x /usr/local/cutycapt/xvfb-run.sh
出現錯誤提示:CutyCapt: cannot connect to X server :99
可以使用命令安裝:
yum install xorg-x11-server-Xvfb
四,安裝中文包
yum install fonts-chinese
五,運行 CutyCapt進行截圖:執行以下命令,如果沒有錯誤,就會在當前目錄下面保存截圖。
/usr/local/cutycapt/xvfb-run.sh –server-args=”-screen 0, 1024x768x24″ /usr/local/cutycapt/CutyCapt –url=http://www.163.com –out=163.jpg
六 ,其他一些相關問題
Q:出現-bash: xvfb-run: command not found 或 xauth : command not found
安裝 yum install Xorg xauth xorg-x11-fonts*(Xorg,xauth,xorg-x11-fonts* 這是三個不同的工具,每個都需要單獨運行yum install來安裝)
Q:錯誤提示:”mktemp: too few X’s in template `Xauthority’.”
找到 AUTHFILE=$(mktemp -p “$XVFB_RUN_TMPDIR” Xauthority)
修改爲:AUTHFILE=$(mktemp -p “$XVFB_RUN_TMPDIR” Xauthority.XXXXXXXX)
Q:錯誤提示:CutyCapt: cannot connect to X server :99
確認server-args參數是否正確,修改xvfb-run.sh脚本中SERVERNUM=99 改爲SERVERNUM=0
Q:截出來的圖片沒有中文字,需要安裝中文字體
yum install cjkuni-ukai-fonts cjkuni-uming-fonts -y
Q:由于截屏的是整個網站的頁面,只需要第一屏幕
convert -crop 1024×768+0+0 163.jpg 1632.jpg
Q:縮小圖片
convert -resize 40%x40% 1632.jpg 1632.jpg
Q:CutyCapt: cannot connect to X server
網上很多都是要在裝個xvfb-run.sh的,其它不用這麽麻煩
echo “export DISPLAY=’:1.0′” >> /etc/profile
source /etc/profile
vncserver
# ./CutyCapt –help
不過每次都輸入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字體
Q:環境變量配置
# vi /etc/profile 未尾加入以下代碼
export QTDIR=/usr/lib/qt44
export QTLIB=/usr/lib/qt44/lib
export QTINC=/usr/lib/qt44/include
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
export PATH=$QTDIR/bin:$PATH
# source /etc/profile

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