1. OpenPLC_Editor在虚拟机上费劲的装了一遍,有些东西已经忘了,主要还是python3 的缺失库版本对应问题,OpenPLC_Editor使用python3编译的,虚拟机的Ubuntu 18.4 有2.7和3.6两个版本,所以需要注意。
2. OpenPLC_Editor 下载地址
3.readme的提示
4.只有简单两句话。
安装执行 >> sudo ./install.sh
运行执行 >> sudo ./openplc_editor.sh
5.主要是运行sudo ./install.sh时报错,各种库缺失,因为有交互界面,需要装一些界面框架库。
5.1 可能会出现 ‘gets’ 问题
./stdio.h:456:1: error: 'gets' undeclared here (not in a function)
报错提示建议用:fgets。
解决办法:
在源码文件夹里搜索找到:stdio.in.h 这个文件。
找到这一行:gets is a security hole 然后将该行注释掉重新编译。
5.2官方手册,需要安装的库
1.2 Installing OpenPLC Editor – Autonomy
6.查看install.sh可以找到需要安装哪些库。
6.1 这一段说明 Ubuntu 需要安装的库,
if [ -x /bin/yum ]; then
yum clean expire-cache
yum check-update
sudo yum -q -y install make automake gcc gcc-c++ bison flex autoconf git python3.9 python3-devel libxml2-devel libxslt-devel gtk3-devel
#Installing dependencies for Ubuntu/Mint/Debian
elif [ -x /usr/bin/apt-get ]; then
sudo apt-get -qq update
#Add deadsnakes PPA for Python3.9 support on newer distros
sudo apt-get install software-properties-common -y
sudo add-apt-repository ppa:deadsnakes/ppa -y
sudo apt-get -qq update
sudo apt-get install -y build-essential bison flex autoconf \
automake make git libgtk-3-dev\
python3.9 python3.9-venv python3.9-dev
#Installing dependencies for opensuse tumbleweed
elif [ -x /usr/bin/zypper ]; then
sudo zypper ref
sudo zypper in -y make automake gcc gcc-c++ bison flex autoconf
sudo zypper in -y python python-xml python3.9 python3-pip
else
echo "Unsupported linux distro."
exit 1
fi
sudo apt-get install build-essential pkg-config bison flex autoconf automake make git
实际测试还需要安装
sudo apt-get install zlib1g-dev
sudo apt-get install libjpeg-dev
sudo apt-get install libgtk-3-dev
6.2 这一段说明 python 需要安装的库:
#Installing Python dependencies
python3.9 -m venv "$VENV_DIR"
"$VENV_DIR/bin/python" -m pip install --upgrade pip
"$VENV_DIR/bin/python" -m pip install wheel jinja2 lxml==4.6.2 future matplotlib zeroconf pyserial pypubsub pyro5 attrdict3
"$VENV_DIR/bin/python" -m pip install wxPython==4.2.0
首先需要安装pip3 :sudo apt install python3-pip
上面这一段源码需要安装Python3.9,会安装失败,这些指令就执行错误,所以我们不需要这一段代码可以删除,可以手动安装。ubuntu 18.04 默认安装的是Python3.6。
手动安装pip3的库:
pip3 install wheel jinja2 six numpy lxml future pillow matplotlib zeroconf pyserial pypubsub pyro5 attrdict3
pip3 install wxPython==4.1.1
6.3 最后需要使用Python3 编译/editor/Beremiz.py文件。
找到这一段,./.venv/bin/python3 ./editor/Beremiz.py" > openplc_editor.sh
直接修改成 python3 ./editor/Beremiz.py" > openplc_editor.sh 前面的路径不需要了。
6.4 以上安装完就可以 sudo ./openplc_editor.sh 运行。
7. 总体都是库的问题,具体看报错,搜相关内容。