如何在服务器或虚拟机搭建matiec运行环境

334 阅读1分钟

1.搭建MinGW-w64交叉编译器(如果是matiec只是本地运行可以不需要这步操作)

git clone https://github.com/Zeranoe/mingw-w64-build.git
./mingw-w64-build x86_64

如果出现missing required executable(s): makeinfo的错误:

sudo apt-get install makeinfo(可以去掉)
sudo apt-get install texinfo

2.安装libtool库

apt install libtool  //将会同时安装autoconf等软件

3.安装bison和flex

apt install bison
apt install flex

Flex和Bison是Linux下用来生成词法分析器和语法分析器两个程序的工具

4.下载matiec源代码

git clone -b develop matiec地址

5.生成congfigure文件

autoreconf -ivf

6.配置环境变量

vim /etc/profile
export PATH=matiec下载路径:${PATH}
export PATH=/root/.zeranoe/mingw-w64/x86_64/bin:${PATH}
. /etc/profile

7.运行matiec

. /etc/profile        //交叉编译才需要执行这个
./configure && make   //本地编译
./configure --host=x86_64-w64-mingw32 && make   //交叉编译(Linux到Windows)
//选择上述其中一种编译得到iec2c二进制文件
iec2c -f -l -p -r -R -a -I matiec下载路径/lib  -T 执行结果保存路径 plc.st文件路径/plc.st  //启动iec2c执行plc.st文件得到C文件

8.打包

maketar.sh
sz -by 文件名