Solved snap7 and Qt Creator
-
Hi and welcome to devnet,
Using Qt Creator you can do it following the documentation here.
-
@SGaist
Thanks a lot.
But it dosnt show how to use the library in the code.
It show how to add the library.
What’s the next step ?Mark
-
@markolino_it said in snap7 and Qt Creator:
But it dosnt show how to use the library in the code.
It's pure c/c++ so what should be explained here?
-
@Christian-Ehrlicher
I am not an user of c/c++.
I have experience with vs and c# where i can add the reference of dll and include it in myClass by a using statement.Can you explain me how to do the same thing ?
I have only .lib and .dll file nothing about .h and .cppThanks a lot
-
@markolino_it said in snap7 and Qt Creator:
Can you explain me how to do the same thing ?
When you want to use a function/class from somewhere you have to include the appropriate header to make the function available for the compiler - you should have done this earlier - otherwise I don't see how you should have compiled a single c++ source file before.
I have only .lib and .dll file nothing about .h and .cpp
There must be a header file for this library, otherwise you won't be able to use it.
-
@Christian-Ehrlicher
Thanks a lot Christian.
I will check it and i let you know asap! -
Ok it works.
So this are the steps to get it works fine:
1-Compile the library with file .bat to obtain .lib and .dll file.
Follow the instruction on snap7 site, section "rebuild".
2-Copy this 2 file in your folder, where found the exe file of the application
3-Copy the snap7.h and the snap7.cpp file of the library (can you found them in the example folder) in the same folder of your .pro file
3-Add an include snap7.h in your widget.h file and declare a TS7Client object.
4-Add in your .pro file LIBS +="path\to\your\file.dll" and run qmakeRemember that if you write or read some data you must swap the byte of the word/longword before you send the request.
I hope this help all the people comes to this post !
That's it :) -
@markolino_it said in snap7 and Qt Creator:
Ok it works.
So this are the steps to get it works fineGlad you solved it. And thank you for sharing your findings.
One more thing, don't forget to mark your post as solved. -
-
@markolino_it
please how can i do step 1 (compile the library with file.bat)