Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

snap7 and Qt Creator



  • Hi to all.
    I'm new to Qt creator and i've need to use snap7 library (i use it already with c# in visual studio) but i have some problems.
    I've found variuos topic about this in the forum, but i see a lot of confusion so i decide to open a new thread.

    This is my problem.
    I've Qt Creator 4.10.0 based on Qt 5.13.1 in my windows 7 64bit.
    From Qt->Tools-Option->Kits i found the path of the compiler MINGW32 for my cpp project and the path is C:\Qt\Qt5.13.1\Tools\mingw730_32\bin\g++.exe and the version is 7.3.0

    So i follow the procedure found here: link text
    MinGW 32bit 4.7.2
    It is assumed that MinGW compiler is installed in C:\MinGW32 and its release is 4.7.2.
    If not, you need to modify make.bat and makefile.

    o In make.bat change the path instruction in the first line to point to the correct compiler path.
    o In makefile change the vars MINGW and MINREL (path and release).
    Pay attention to not leave trailing spaces after the text.

    So my make file is:
    path=C:\Qt\Qt5.13.1\Tools\mingw730_32\bin;%PATH
    mingw32-make %1

    and make file is:
    MINGW =C:\Qt\Qt5.13.1\Tools\mingw730_32\bin
    MINREL =7.0.3

    but when i launche make.bat from the prompt i receive this error:
    alt text

    What can i do ?
    Thanks a lot,
    Mark



  • Update:
    with MinGW 32bit 4.7.2 if i follow the procedure i get my .lib and .dll file
    So now how i can use them in my Qt Creator project ?


  • Lifetime Qt Champion

    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


  • Lifetime Qt Champion

    @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 .cpp

    Thanks a lot


  • Lifetime Qt Champion

    @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 qmake

    Remember 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 fine

    Glad you solved it. And thank you for sharing your findings.
    One more thing, don't forget to mark your post as solved.



  • @Pablo-J-Rogina
    👍🏻


Log in to reply