Tesseract 源码编译开发环境

编译环境

在 wsl 环境下进行编译的 tesseract 5 版本

# 安装图像处理库
sudo apt install libleptonica-dev -y 

# 安装环境依赖
sudo apt install libicu-dev libpango1.0-dev libcairo2-dev -y

# 执行编译
cd tesseract-ocr && mkdir -p build && cd build && cmake .. && make

开发环境

clion 中使用 wsl 作为开发环境

  • 安装基础包
sudo apt-get update
sudo apt-get install cmake gcc clang gdb build-essential
  • 安装配置 sshd
  1. 创建安装脚本 ubuntu_setup_env.sh
#!/bin/bash
set -e

SSHD_LISTEN_ADDRESS=0.0.0.0
# 注启动的 2222 端口哦
SSHD_PORT=2222
SSHD_FILE=/etc/ssh/sshd_config
SUDOERS_FILE=/etc/sudoers
  
# 0. update package lists
sudo apt-get update

# 0.1. reinstall sshd (workaround for initial version of WSL)
sudo apt remove -y --purge openssh-server
sudo apt install -y openssh-server

# 0.2. install basic dependencies
sudo apt install -y cmake gcc clang gdb valgrind build-essential

# 1.1. configure sshd
sudo cp $SSHD_FILE ${SSHD_FILE}.`date '+%Y-%m-%d_%H-%M-%S'`.back
sudo sed -i '/^Port/ d' $SSHD_FILE
sudo sed -i '/^ListenAddress/ d' $SSHD_FILE
sudo sed -i '/^UsePrivilegeSeparation/ d' $SSHD_FILE
sudo sed -i '/^PasswordAuthentication/ d' $SSHD_FILE
echo "# configured by CLion"      | sudo tee -a $SSHD_FILE
echo "ListenAddress ${SSHD_LISTEN_ADDRESS}" | sudo tee -a $SSHD_FILE
echo "Port ${SSHD_PORT}"          | sudo tee -a $SSHD_FILE
echo "UsePrivilegeSeparation no"  | sudo tee -a $SSHD_FILE
echo "PasswordAuthentication yes" | sudo tee -a $SSHD_FILE
# 1.2. apply new settings
sudo service ssh --full-restart
  
# 2. autostart: run sshd 
sed -i '/^sudo service ssh --full-restart/ d' ~/.bashrc
echo "%sudo ALL=(ALL) NOPASSWD: /usr/sbin/service ssh --full-restart" | sudo tee -a $SUDOERS_FILE
cat << 'EOF' >> ~/.bashrc
sshd_status=$(service ssh status)
if [[ $sshd_status = *"is not running"* ]]; then
  sudo service ssh --full-restart
fi
EOF
  

# summary: SSHD config info
echo 
echo "SSH server parameters ($SSHD_FILE):"
echo "ListenAddress ${SSHD_LISTEN_ADDRESS}"
echo "Port ${SSHD_PORT}"
echo "UsePrivilegeSeparation no"
echo "PasswordAuthentication yes"
  1. 执行脚本
sudo chmod +x ubuntu_setup_env.sh
bash ubuntu_setup_env.sh

重启 windows ,sshd 服务会自动启动

  • 测试 sshd 服务
ssh username@localhost -p2222

usernamewindows 登录账号及其密码

  • 配置 clion

依次 Settings / Preferences | Build, Execution, Deployment | Toolchains,从环境列表中选择 WSLCLion 会自动检测已安装的发行版,或者手动设置路径。

`CLion` 会自动检测已安装的发行版

你可能感兴趣的:(Tesseract 源码编译开发环境)