Coding and Life

记录点点滴滴

嗨,我是徐斌,一位PHP开发者。


感谢您浏览我的博客

centos7 安装opencc

第一步:升级gcc和g++

//查看当前gcc版本
gcc --version
g++ --version
//下载对应版本
cd /usr/local/src
wget http://ftp.gnu.org/gnu/gcc/gcc-5.2.0/gcc-5.2.0.tar.bz2
tar -jxvf gcc-5.2.0.tar.bz2
//进入gcc目录安装
cd gcc-5.2.0
./contrib/download_prerequisites
//创建bulid文件夹
mkdir build
cd build
../configure --prefix=/usr/local/gcc --enable-languages=c,c++ --disable-multilib
//编译安装,此过程耗时较长
make
make install
//修改软连接
mv /usr/bin/gcc /usr/bin/gcc_old
ln -s /usr/local/gcc/bin/gcc /usr/bin/gcc
mv /usr/bin/g++ /usr/bin/g++_old
ln -s /usr/local/gcc/bin/g++ /usr/bin/g++
//查看升级后版本
gcc --verson
g++ --version

第二步: 安装cmake 和 doxygen

 yum install cmake
 yum install doxygen

第三步:克隆opencc

git clone https://github.com/BYVoid/OpenCC.git
cd OpenCC
make
sudo make install

第四步: 处理opecc make安装出现的报错

错误信息:

c++: error: unrecognized command line option ‘-std=c++14

解决办法:

cmake -DCMAKE_CXX_COMPILER=/usr/local/gcc/bin/g++ .
//指定g++路径

错误信息:

[ 62%] Building STCharacters.ocd2
../src/tools/opencc_dict: /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by ../src/tools/opencc_dict)
../src/tools/opencc_dict: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ../src/tools/opencc_dict)
../src/tools/opencc_dict: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /home/OpenCC-ver.1.1.2/src/libopencc.so.1.1)
../src/tools/opencc_dict: /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /home/OpenCC-ver.1.1.2/src/libopencc.so.1.1)
../src/tools/opencc_dict: /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /home/OpenCC-ver.1.1.2/src/libopencc.so.1.1)
../src/tools/opencc_dict: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /home/OpenCC-ver.1.1.2/src/libopencc.so.1.1)
make[2]: *** [data/STCharacters.ocd2] Error 1
make[1]: *** [data/CMakeFiles/Dictionaries.dir/all] Error 2
make: *** [all] Error 2

解决办法:

find / -name "libstdc++.so*" //查找编译gcc时生成的最新动态库
cp ./libstdc++.so.6.0.21 /usr/lib64/ //把libstdc++.so.6.0.21拷贝到/usr/lib64目录下
rm -rf /usr/lib64/libstdc++.so.6 //删除以前的libstdc++.so.6
ln -s /usr/lib64/libstdc++.so.6.0.21 /usr/lib64/libstdc++.so.6  //建立新连接

错误信息:

opencc: error while loading shared libraries: libopencc.so.1.1: cannot open shared object file: No such file or directory

解决办法

$ find / -name libopencc.so.1.1
ln -s /usr/lib/libopencc.so.1.1 /usr/lib64/libopencc.so.1.1 //建立新连接

第五步 open4cc

git clone git@github.com:NauxLiu/opencc4php.git
cd opencc4php
phpize
./configure --with-php-config=/you/path/php-config
make && sudo make install

第六部 可能遇到的问题

错误信息

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_US:en",
LC_ALL = (unset),
LC_CTYPE = "zh_CN.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_US:en",
LC_ALL = (unset),
LC_CTYPE = "zh_CN.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").

解决方案

vi /root/.bashrc
export LC_ALL=C //底部添加
source /root/.bashrc //保存完执行命令
最近的文章

路由器设置

继续阅读
更早的文章

truncate 清库

继续阅读