当前位置: 首页 > news >正文

Ethercat系列(10)用QT实现SOEM主站

  1. 首先将SOEM编译成静态Lib库

可以参考前面的博文

(83条消息) VS2017下编译SOEM(Simle Open EtherCAT Master)_soem vs_CoderIsArt的博客-CSDN博客

make_libsoem_lib.bat "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build" x86

  1. 用QT创建控制台程序并导入静态库

工程文件如下,

QT -= guiCONFIG += c++11 console
CONFIG -= app_bundle# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGSDEFINES += HAVE_STRUCT_TIMESPEC  #to void timespec redefinition compain# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0SOURCES += \main.cpp# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += targetwin32: LIBS += -L$$PWD/libs/ -llibsoemINCLUDEPATH += $$PWD/libsINCLUDEPATH += $$PWD/includeDEPENDPATH += $$PWD/libswin32:!win32-g++: PRE_TARGETDEPS += $$PWD/libs/libsoem.lib
else:win32-g++: PRE_TARGETDEPS += $$PWD/libs/liblibsoem.aHEADERS += \include/ethercatbase.h \include/ethercatcoe.h \include/ethercatconfig.h \include/ethercatdc.h \include/ethercatfoe.h \include/ethercatmain.h \include/ethercatprint.h \include/ethercatsoe.h \include/ethercattype.h \include/nicdrv.h \include/osal.h \include/osal_defs.h \include/osal_win32.hwin32: LIBS += -L$$PWD/wpcap/Lib/ -lwpcapINCLUDEPATH += $$PWD/wpcap/Include
DEPENDPATH += $$PWD/wpcap/Includewin32:!win32-g++: PRE_TARGETDEPS += $$PWD/wpcap/Lib/wpcap.lib
else:win32-g++: PRE_TARGETDEPS += $$PWD/wpcap/Lib/libwpcap.aunix|win32: LIBS += -L$$PWD/wpcap/Lib/ -lPacketINCLUDEPATH += $$PWD/wpcap/Include/pcap
DEPENDPATH += $$PWD/wpcap/Include/pcap
  1. 修改一些必要的头文件

工程中有些头文件,没有对在C++环境中编译作处理,需要作如下处理。

#ifdef _cplusplus

extern "C" {

#endif

#ifdef _cplusplus

}

#endif

  1. 加入缺少的系统库

#pragma comment(lib,"libsoem.lib")

#pragma comment(lib,"Packet.lib")

#pragma comment(lib,"wpcap.lib")

#pragma comment(lib,"ws2_32.lib")

#pragma comment(lib,"winmm.lib")

  1. 运行结果

http://www.lryc.cn/news/26553.html

相关文章:

  • 论文投稿指南——中文核心期刊推荐(科学、科学研究)
  • jQuery属性操作prop()、attr()和data()
  • git的使用
  • webpack生产环境配置
  • linux下安装jenkins
  • IGKBoard(imx6ull)-I2C接口编程之SHT20温湿度采样
  • MyBatis——配置文件完成增删改查
  • Python内置函数 — all,any
  • Pycharm配置QGIS环境
  • 【C++】stack 与 queue
  • ARC142E Pairing Wizards
  • Spark开发实战-主播打赏排行榜统计
  • python 如何存储数据 (python 的文件和异常)
  • 第三章-OpenCV基础-8-绘图函数
  • 逆约瑟夫问题
  • MySQL之三大日志(更新中)
  • 如何使用EvilTree在文件中搜索正则或关键字匹配的内容
  • 北京移动CM311-5s-ZG_GK6323V100C_2+8_免拆一键卡刷固件包
  • JavaScript(1)
  • 阿里云云原生每月动态 | 聚焦实战,面向开发者的系列课程全新上线
  • Goby 征文大擂台,超值盲盒等你来!
  • NLP - langid 语种识别
  • liquibase学习和使用
  • redhawk:Low Power Analysis
  • 24- 深度学习的模型保存和加载 (TensorFlow系列) (深度学习)
  • 【Echarts图例点击事件】自定义Echarts图例legend点击事件(已解决)
  • uniapp-首页配置
  • 支持DDR5,超频更简单,小雕够给力,技嘉B760M小雕WIFI主板上手
  • fengMap 自定义dom 偏离实际位置;缩放时飘出地图所在区域
  • TryHackMe-黑我杯