前言
项目中用到
libplctag,先在Ubuntu上安装一下
一、libplctag 是什么?
libplctag is an open source C library for Linux, Windows and macOS using EtherNet/IP or Modbus TCP to read and write tags in PLCs. The library has been in production since early 2012 and is used by multiple organizations for many tasks including controlling radio telescopes, large and precision manufacturing, controlling fitness equipment, food handling and many, many more.
Current Stable Version: 2.4
Old Stable Version: 2.3
GitHub - libplctag/libplctag: This C library provides a portable and simple API for accessing Allen-Bradley and Modbus PLC data over Ethernet.
二、使用步骤 1.安装环境工具Run cmake (use "Release" for a release build and "Debug" for a debug build).
$> cmake .. -DCMAKE_BUILD_TYPE=Release
编译过程发现如下提示:
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
Visual Studio Community 2019 with Windows 10 (19.03)
Microsoft has integrated GitHub and CMake into VS 2019 very nicely. It is highly recommended to use at least this version as the integration
has made the process much easier than in the past!
- Download at least Visual Studio 2019. I use the Community, free, version.
- Make sure that you select the C++ command line parts when selecting the components to install. This installs the C part too.
- After installation, start VS 2019.
- Select "Clone or Check out code" over on the top right of the splash/start up screen.
- Enter the link information for the libplctag GitHub project.
- This churns for a while (at least in a VM on a fast laptop with a NVMe drive, your wait time may vary).
- VS 2019 will notice that this is a CMake-based project and automatically start setting everything up.
- Once this is done, you should be able to build the project.
- Project binaries may take a little bit of a hunt to find. If anyone has any tips on how to instruct VS through CMake to do something a little more obvious here, I would love to know!



