建立一个文件夹,并将源码包解压到新建的文件夹中,然后cd到这个文件夹中。
执行./configure,提示:
To build the program, run qmake, then make. The following dependency packages are required: libvorbis-dev, zlib1g-dev, libhunspell-dev, x11proto-record-dev, qt4-qmake, libqt4-dev, g++, libxtst-dev, libphonon-dev. They can be named slightly different in different distributions. |
执行如下命令安装所需依赖,这里安装的版本都是Fedora-18-x86_64-DVD.iso自带的版本:
yum install libvorbis-devel zlib-devel hunspell-devel xorg-x11-proto-devel qt-devel qtwebkit-devel libXtst-devel phonon-devel
执行qmake-qt4,提示:
fatal: Not a git repository (or any parent up to mount point /home) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set). Project MESSAGE: Failed to precisely describe the version via Git -- using the default version string |
这是可能是git需要联网下载更新失败而出现的错误,无视之。
执行make,出现如下错误信息:
processwrapper.cc: In static member function ‘static unsigned int ProcessWrapper::currentProcessId()’: processwrapper.cc:99:19: error: ‘getpid’ was not declared in this scope processwrapper.cc:100:1: warning: control reaches end of non-void function [-Wreturn-type] make: *** [build/processwrapper.o] Error 1 |
执行如下命令:
grep -r "getpid" *
输出信息如下:
processwrapper.cc: returngetpid(); |
只找到了一个源文件中包含getpid,说明getpid是系统环境中的。
通过搜索"getpid was not declared in this scope",发现getpid在/usr/include/unistd.h这个头文件中,
于是通过分析processwrapper.cc,在这个源文件中的"#else"后添加"#include <unistd.h>"(注意添加到源文件中时不要带引号)。
再次执行make,又出现如下错误信息:
qtsingleapplication/src/qtlocalpeer.cpp: In constructor ‘QtLocalPeer::QtLocalPeer(QObject*, const QString&)’: qtsingleapplication/src/qtlocalpeer.cpp:96:54: error: ‘::getuid’ has not been declared qtsingleapplication/src/qtlocalpeer.cpp:96:54: note: suggested alternative: In file included from qtsingleapplication/src/qtlockedfile_unix.cpp:42:0, from qtsingleapplication/src/qtlocalpeer.cpp:60: /usr/include/unistd.h:697:16: note: ‘QtLP_Private::getuid’ make: *** [build/qtlocalpeer.o] Error 1 |
通过分析qtsingleapplication/src/qtlocalpeer.cpp,在这个源文件中的"#include <time.h>"后添加"#include <unistd.h>"(注意添加到源文件中时不要带引号)。
再执行make,编译通过了。
然后就是执行make install了。
安装完后,发现程序菜单中的GoldenDict没有图标,
执行vim /usr/local/share/applications/goldendict.desktop,
发现Icon=/usr/share/pixmaps/goldendict.png指定的png文件不存在,
执行ll /usr/local/share/pixmaps/goldendict.png,发现png文件原来在这,
于是修改为Icon=/usr/local/share/pixmaps/goldendict.png,
程序菜单中的GoldenDict就有图标了。
PS:不知道为什么GoldenDict使用词典需要执行权限,安装词典时,如果词典放在了/usr/local/share等非root用户有权限限制的地方,需要使用如下命令为词典文件添加执行权限:
chmod -R 755 dictionaries