ubuntu版本安装
1.下载kenlm安装包
https://pypi.org/project/kenlm/#files
wget https://files.pythonhosted.org/packages/57/54/0cc492b8d7aceb17a9164c6e6b9c9afc2c73706bb39324e8f6fa02f7134a/kenlm-0.tar.gz
2.安装依赖包
apt install libboost-dev libboost-test-dev
sudo apt-get install libboost-all-dev
sudo apt install libbz2-dev
sudo apt install liblzma-dev
sudo apt-get install libeigen3-dev
3.编译安装
cd kenlm
mkdir -p build
cd build
cmake ..
make -j 4
4.配置环境变量
vim ~/.bashrc
export PATH=$PATH:/home/jason/kenlm/build/bin/
source ~/.bashrc
Centos版本安装
1.下载kenlm安装包
https://pypi.org/project/kenlm/#files
wget https://files.pythonhosted.org/packages/57/54/0cc492b8d7aceb17a9164c6e6b9c9afc2c73706bb39324e8f6fa02f7134a/kenlm-0.tar.gz
2.编译安装
cd kenlm
mkdir -p build
cd build
cmake .. # 执行该步骤的时候,可能会遇到2.1~2.5的错误
make -j 4
2.1.错误1(cmake: command not found)
cmake: command not found
此时,需要下载安装cmake
参考https://www.cnblogs.com/jsdy/p/12689470.html
wget http://www.cmake.org/files/v3.16/cmake-3.16.6.tar.gz
tar xf cmake-3.16.6.tar.gz
cd cmake-3.16.6
sudo apt-get install build-essential
./bootstrap # 耗时较久
make
make install
cmake --version # 验证
2.2.错误2(Could NOT find Eigen3)
此时,需要下载安装Eigen3
参考:https://blog.csdn.net/p942005405/article/details/100653731
git clone https://github.com/eigenteam/eigen-git-mirror
#安装
cd eigen-git-mirror
mkdir build
cd build
cmake ..
sudo make install
#安装后,头文件安装在/usr/local/include/eigen3/
#移动头文件
sudo cp -r /usr/local/include/eigen3/Eigen /usr/local/include
2.3.错误3(Boost错误)
CMake Error at /usr/share/cmake-3.5/Modules/FindBoost.cmake:1677 (message):
Unable to find the requested Boost libraries.
此时,需要下载安装Boost
参考:https://blog.csdn.net/Nicholas_Wong/article/details/80013547
wget https://boostorg.jfrog.io/artifactory/main/release/1.67.0/source/boost_1_67_0.tar.gz
tar --bzip2 -xf boost_1_67_0.tar.bz2
cd boost_1_67/
./bootstrap.sh --prefix=/usr/local#参数制定安装的位置
sudo ./b2 install --with=all#编译安装所有的库,根据前面设置的安装位置的不同,这里可能需要使用sudo权限
2.4.错误4(BZip2错误)
-- Could NOT find BZip2 (missing: BZIP2_LIBRARIES BZIP2_INCLUDE_DIR)
此时,需要下载安装BZip2
sudo yum install bzip2-devel
2.5.错误5(LibLZMA错误)
-- Could NOT find LibLZMA (missing: LIBLZMA_INCLUDE_DIR LIBLZMA_LIBRARY LIBLZMA_HAS_AUTO_DECODER LIBLZMA_HAS_EASY_ENCODER LIBLZMA_HAS_LZMA_PRESET)
此时,需要下载安装BZip2
sudo yum install xz-devel.x86_64