Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Snap7 and Qt ,PLC communication
Forum Updated to NodeBB v4.3 + New Features

Snap7 and Qt ,PLC communication

Scheduled Pinned Locked Moved Unsolved General and Desktop
37 Posts 6 Posters 11.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    ZekDe
    wrote on last edited by
    #12

    I am downloading all mingw versions![alt text](0_1515853830620_b7bf5064-b84a-49f5-8f4d-b8646509ef11-image.png image url)

    aha_1980A 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #13

      :)
      but why ???
      The Qt 5.0.2 mingw Qt contains one.
      There should be no need to add extra compilers from "tools" unless you expect the one
      in Qt is too new for snap7

      1 Reply Last reply
      1
      • Z ZekDe

        I am downloading all mingw versions![alt text](0_1515853830620_b7bf5064-b84a-49f5-8f4d-b8646509ef11-image.png image url)

        aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by
        #14

        Hi @ZekDe,

        personally I would not use MinGW 4.7 anymore. It's an old compiler. Also Qt 5.0 and 5.1 are very early 5.x versions, I would not use them for new development. You may encounter bugs that were already fixed in later versions (we have 5.10 now!)

        If there is no Snap7 version compatible with a recent MinGW, I would try to compile the library myself.

        It may be more work in the beginning, but that time will be saved in later development for sure.

        Just my two cent.

        Qt has to stay free or it will die.

        1 Reply Last reply
        2
        • Z Offline
          Z Offline
          ZekDe
          wrote on last edited by
          #15

          The reason that I install the all mingw because of if I need other one,is it wrong ? :), Also Maybe you saw the src folder n snap7 folder.Can I use these in my project ,in this case it is enough now.But When I try these .h and .c files ,I encountered some problems.What excatly I should do.Because this is important for my job

          mrjjM 1 Reply Last reply
          0
          • Z ZekDe

            The reason that I install the all mingw because of if I need other one,is it wrong ? :), Also Maybe you saw the src folder n snap7 folder.Can I use these in my project ,in this case it is enough now.But When I try these .h and .c files ,I encountered some problems.What excatly I should do.Because this is important for my job

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #16

            @ZekDe
            Hi , yes you might be able to include the source files directly in the Qt app unless snap7 is
            designed to be a lib. Installing multiple version of mingw will open up for a mess with paths etc.

            If directly including them (and fixing the .pro file so it can find its headers) still produces errors, it might not
            allow direct use and must be build as DLL.

            1 Reply Last reply
            0
            • Z Offline
              Z Offline
              ZekDe
              wrote on last edited by
              #17

              as a result,What is your offer now?

              mrjjM 1 Reply Last reply
              0
              • Z ZekDe

                as a result,What is your offer now?

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #18

                @ZekDe
                Offer ?
                All info is there. they even made .bat files to compile the DLL
                so build it and link it to the Qt app.
                It has clear build instruction.

                1 Reply Last reply
                1
                • Z Offline
                  Z Offline
                  ZekDe
                  wrote on last edited by
                  #19

                  I suppose I have lack of knowledge,I dont know about .bat file.How will I use it?What does it do

                  mrjjM 1 Reply Last reply
                  0
                  • Z ZekDe

                    I suppose I have lack of knowledge,I dont know about .bat file.How will I use it?What does it do

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by mrjj
                    #20

                    @ZekDe
                    First read its build dosc.
                    You might need to alter paths to where it looks for compiler
                    Then open a Command prompt and run the bat file for
                    mingw32 or 64 (depending on what u use)
                    It should produce a DLL you can link to your app as described.

                    1 Reply Last reply
                    2
                    • Z Offline
                      Z Offline
                      ZekDe
                      wrote on last edited by
                      #21

                      Check me then if I understand right.
                      1-->I will build a .dll using .bat according to mingw file path,I will chance in bat file.
                      2-->I will put in my Qt app .dll, .lib and I include the snap7.lib in .pro file
                      Then Qt will see both because of the .dll and .lib same folder.

                      mrjjM 1 Reply Last reply
                      0
                      • Z Offline
                        Z Offline
                        ZekDe
                        wrote on last edited by
                        #22

                        Okay I said wrong as far as I see.
                        To build Snap7, open a command prompt into the working folder build\windows\MinGW32 and run "make all" (or "make clean" if you want to clean the project).
                        How can I open a command promt in working folder ,it means a txt file?and then convert .bat.Still I am confused.How can I assembly all.I have Makefile,.bat,.lib..dll.I have new version Mingw this is why I need to change in .bat file.When I click this what will happen,will it produce a makefile? then How will I make out with them all in Qt

                        1 Reply Last reply
                        0
                        • Z ZekDe

                          Check me then if I understand right.
                          1-->I will build a .dll using .bat according to mingw file path,I will chance in bat file.
                          2-->I will put in my Qt app .dll, .lib and I include the snap7.lib in .pro file
                          Then Qt will see both because of the .dll and .lib same folder.

                          mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by
                          #23

                          @ZekDe
                          Hi
                          seems fine if 2:
                          is
                          INCLUDEPATH += /path/include ( points to where ever Snap7 .h file livrd
                          LIBS += -L"c:/fullpath/lib" -lCatWhisperer

                          and "c:/fullpath/lib" is corrected to point to the folder that contains the DLL you just build
                          and CatWhisperer be replaced with actual filename

                          1 Reply Last reply
                          0
                          • mrjjM Offline
                            mrjjM Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on last edited by mrjj
                            #24
                            • how can I open a command prompt in working folder

                            just open one and navigate to the folder using command. :)
                            like
                            cd c:\xxx\yyy

                            You dont convert the BAT file. u run it

                            It might produce a make file and you can run mingw make on it

                            1 Reply Last reply
                            0
                            • Z Offline
                              Z Offline
                              ZekDe
                              wrote on last edited by
                              #25

                              path=c:\MinGW32\bin;c:\MinGW32\mingw32\bin;%PATH
                              mingw32-make %1
                              this is in .bat
                              and he said me
                              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.
                              My mingw like you know in another folder.I will change it in the command line? and How?And I don't stil lunderstand how the makefile will be used in Qt,Am I missing something.And Thank you so much your helps,I learned very important knowledges

                              1 Reply Last reply
                              1
                              • M Offline
                                M Offline
                                mmiacca
                                wrote on last edited by
                                #26

                                Hi... i'm using SNAP7 compiled with mingw inside qtcreator... i can compile and also debug SNAP7 along with my HMI software...
                                If you can wait until monday i'll send you the complete project so you can have an easy start...

                                1 Reply Last reply
                                3
                                • Z Offline
                                  Z Offline
                                  ZekDe
                                  wrote on last edited by
                                  #27

                                  Thank you mmiacca ,I can wait and also How did you manage it if you explain I will be so happy.

                                  1 Reply Last reply
                                  0
                                  • Z Offline
                                    Z Offline
                                    ZekDe
                                    wrote on last edited by
                                    #28

                                    Are you able to do it with mingw 5.3.0?

                                    1 Reply Last reply
                                    0
                                    • Z Offline
                                      Z Offline
                                      ZekDe
                                      wrote on last edited by
                                      #29

                                      Hi mmiacca ,could you give me an example ?,I need like you ssay,I need easy start

                                      1 Reply Last reply
                                      0
                                      • M Offline
                                        M Offline
                                        mmiacca
                                        wrote on last edited by
                                        #30

                                        Hi (excuse my english please)

                                        Here is the project file to compile a gui example with snap7, no libraries, all in one..

                                        #-------------------------------------------------
                                        #
                                        # Project created by QtCreator 2016-11-17T17:37:17
                                        #
                                        #-------------------------------------------------
                                        
                                        QT += core gui network
                                        
                                        greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
                                        
                                        TARGET = test1
                                        
                                        TEMPLATE = app
                                        
                                        # Desde http://stackoverflow.com
                                        # Finally, CONFIG(debug, debug|release) evaluates to true if CONFIG contains "debug" but not "release", or if it contains both
                                        # "debug" and "release" but "release" doesn't appear after the last occurrence of "debug".
                                        CONFIG(debug, debug|release){
                                         DESTDIR = $$_PRO_FILE_PWD_/../debug
                                         #DEFINES += QT_NO_DEBUG
                                        }
                                        else{
                                         DESTDIR = $$_PRO_FILE_PWD_/../release
                                        }
                                        
                                        win32:LIBS += C:\Qt\Tools\mingw530_32\i686-w64-mingw32\lib\libws2_32.a
                                        win32:LIBS += C:\Qt\Tools\mingw530_32\i686-w64-mingw32\lib\libwinmm.a
                                        
                                        INCLUDEPATH += ../snap7-full-1.4.1/release/Wrappers/c-cpp/ \
                                                       ../snap7-full-1.4.1/src/lib/ \
                                                       ../snap7-full-1.4.1/src/core/ \
                                                       ../snap7-full-1.4.1/src/sys/
                                        
                                        SOURCES += main.cpp\
                                         mainwindow.cpp \
                                            client.cpp \
                                            ../snap7-full-1.4.1/release/Wrappers/c-cpp/snap7.cpp \
                                            ../snap7-full-1.4.1/src/core/s7_client.cpp \
                                            ../snap7-full-1.4.1/src/core/s7_isotcp.cpp \
                                            ../snap7-full-1.4.1/src/core/s7_micro_client.cpp \
                                            ../snap7-full-1.4.1/src/core/s7_partner.cpp \
                                            ../snap7-full-1.4.1/src/core/s7_peer.cpp \
                                            ../snap7-full-1.4.1/src/core/s7_server.cpp \
                                            ../snap7-full-1.4.1/src/core/s7_text.cpp \
                                            ../snap7-full-1.4.1/src/lib/snap7_libmain.cpp \
                                            ../snap7-full-1.4.1/src/sys/snap_msgsock.cpp \
                                            ../snap7-full-1.4.1/src/sys/snap_sysutils.cpp \
                                            ../snap7-full-1.4.1/src/sys/snap_tcpsrvr.cpp \
                                            ../snap7-full-1.4.1/src/sys/snap_threads.cpp
                                        
                                        HEADERS += mainwindow.h \
                                            client.h \
                                            ../snap7-full-1.4.1/release/Wrappers/c-cpp/snap7.h \
                                            ../snap7-full-1.4.1/src/core/s7_client.h \
                                            ../snap7-full-1.4.1/src/core/s7_firmware.h \
                                            ../snap7-full-1.4.1/src/core/s7_isotcp.h \
                                            ../snap7-full-1.4.1/src/core/s7_micro_client.h \
                                            ../snap7-full-1.4.1/src/core/s7_partner.h \
                                            ../snap7-full-1.4.1/src/core/s7_peer.h \
                                            ../snap7-full-1.4.1/src/core/s7_server.h \
                                            ../snap7-full-1.4.1/src/core/s7_text.h \
                                            ../snap7-full-1.4.1/src/core/s7_types.h \
                                            ../snap7-full-1.4.1/src/lib/snap7_libmain.h \
                                            ../snap7-full-1.4.1/src/sys/snap_msgsock.h \
                                            ../snap7-full-1.4.1/src/sys/snap_platform.h \
                                            ../snap7-full-1.4.1/src/sys/snap_sysutils.h \
                                            ../snap7-full-1.4.1/src/sys/snap_tcpsrvr.h \
                                            ../snap7-full-1.4.1/src/sys/snap_threads.h \
                                            ../snap7-full-1.4.1/src/sys/sol_threads.h \
                                            ../snap7-full-1.4.1/src/sys/unix_threads.h \
                                            ../snap7-full-1.4.1/src/sys/win_threads.h
                                        
                                        FORMS += mainwindow.ui
                                        
                                        

                                        But the full project is here https://drive.google.com/file/d/1AWX3xe00D-WWrQwFGi18juR8KBkYkB7V/view?usp=sharing ... also the snap7 project... i'm using qt 5.9.2 with mingw... install it with default options...

                                        Hope this help

                                        1 Reply Last reply
                                        2
                                        • Z Offline
                                          Z Offline
                                          ZekDe
                                          wrote on last edited by ZekDe
                                          #31
                                          This post is deleted!
                                          1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved