Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Including 3rd party lib
I'm playing with TwinCAT 3 to discover it
I did a simple PLC.
TwinCAT has libraries that allow user to communicate with the runtime.
im trying to access my PLC from my Qt program.
This is the official sample (Example 6: Start/stop PLC) to turn ON / OFF the PLC using the TwinCATs libs
So im trying to include the same libraries (they are in the TwinCAT install dir on my pc) in my program like this
#TwinCAT Libs INCLUDEPATH += C:/TwinCAT/AdsApi/TcAdsDll/Include # .h files are here LIBS += -LC:/TwinCAT/AdsApi/TcAdsDll/Lib -lTcAdsDll # .lib is here
Now includes looks good because QtCreator recognizes the types from the lib but when i try to compile i get
C:\TwinCAT\AdsApi\TcAdsDll\Include\TcAdsApi.h:143: erreur : 'BOOL' was not declared in this scope
in the TcAdsApi.h file
__declspec( dllexport ) long __stdcall AdsAmsPortEnabled(BOOL *pbEnabled);
what could be my problem please ?
@lelev What compiler do you use?
@jsulm mingw73_32 but also tested msvc2017.
In the include path C:/TwinCAT/AdsApi/TcAdsDll/Include
there are 2 files
andin the lib folder ther is only
@jsulm it is included first. I tried to include it as 2nd and indeed there are much more errors
@jsulm i 'solved' issuses but i think wrong way.
i edited the TcAdsAPI file (i should not right ?) , i added #include "TcAdsDef.h" , that solved lot of unknown type errors, but there was still a last unknown type BOOL so i did
#define BOOL bool
now it compiles without errors and i can communicate with my PLC
because i edited the files i copied and moved them to another directory to not currupt the original TwinCAT installation files.
I expect errors maybe because of the BOOL
Btw: interesting project. can you share it?
@aha_1980 thank you for the link
this is only the beginning of the project, i'm trying to integrate the ADS libraries of twincat beckhoff, and make a QML API. If i can achieve something decent i will share it
this is one Qt based Beckhoffs ADS implementation https://github.com/stefanbesler/QAds by Stefan Besler
paul_espinosa last edited by
@paul_espinosa hi, i have very small experience with it. I finnaly used Beckhoff Tc3OpcUa module to create a opcua server that gives me access to the Plc, and i developed the client application using QtOpcUa
Hello @LeLev Why did you decide to move from ADS to OpcUa? I guess you had to buy the OpcUa module license?
@NikoLeben Mainly for the convenience of QtOpcua,
yes you have to buy Beckhoff TcOpcuaServer licence and qtopcua licence
NikoLeben last edited by NikoLeben
@LeLev The OpcUa seems a nice solution but expensive. ~1000€ for performance class 90. Do you still have the QT code for ADS? seems that the git from 2 years back is not working.
This post is deleted!
Do you still have the QT code for ADS?
what do you mean by "QT code for ADS" ?
@LeLev If you still have the project where you had a successful communication with PLC. My application crashes once I try to use the Tc3Manager
@LeLev Even better! Could you perhaps send it to me?
ekiz_osman last edited by
@LeLev and others
I want to communicate with qt ads can you help?
I use twincat
For example-1: https://web.itu.edu.tr/~yanikgo/BeckhoffCSVDatalogger(EN).pdf
I think that if I run the project in this link in qt it will fulfill what I want to do?
For example-2: http://pe2a.com/blog/2016/08/31/beckhoff-pc-ads-haberlesmesi-cc-uzerinden/, when i want to run the project in this link in qt i get the following error: undefined reference to `AdsPortOpen '
I would be glad if you help with the above problems. Thanks
when i want to run the project in this link in qt i get the following error: undefined reference to `AdsPortOpen '
I guess you have to link aganst the lib containing AdsPortOpen? According to the documentation it is TcAdsDll.
ekiz_osman last edited by
@NikoLeben Can you send me this proje?