Click here to Skip to main content
15,904,156 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello friends,I have lack of information about makefile.Could you help me to understand that event.I managed to be communicated PC and PLC now that is makefile from SNAP7 file and other one is my .pro file from QT Creature.Could you explain MakeFile content.

#               
# MinGW 32 makefile
#
# Change vars MINGW and MINREL in accord to your compiler path/release
#                
MINGW    =C:/MinGW32
MINREL   =4.7.2
#
#
CPP      = g++.exe
CC       = gcc.exe
TEMP     =../../temp
OBJ      = $(TEMP)/win32/snap_msgsock.o $(TEMP)/win32/snap_sysutils.o $(TEMP)/win32/snap_tcpsrvr.o $(TEMP)/win32/snap_threads.o $(TEMP)/win32/s7_client.o $(TEMP)/win32/s7_isotcp.o $(TEMP)/win32/s7_micro_client.o $(TEMP)/win32/s7_partner.o $(TEMP)/win32/s7_peer.o $(TEMP)/win32/s7_server.o $(TEMP)/win32/s7_text.o $(TEMP)/win32/snap7_libmain.o
LINKOBJ  = $(TEMP)/win32/snap_msgsock.o $(TEMP)/win32/snap_sysutils.o $(TEMP)/win32/snap_tcpsrvr.o $(TEMP)/win32/snap_threads.o $(TEMP)/win32/s7_client.o $(TEMP)/win32/s7_isotcp.o $(TEMP)/win32/s7_micro_client.o $(TEMP)/win32/s7_partner.o $(TEMP)/win32/s7_peer.o $(TEMP)/win32/s7_server.o $(TEMP)/win32/s7_text.o $(TEMP)/win32/snap7_libmain.o
LIBS     = -L"$(MINGW)/lib" -static-libgcc --no-export-all-symbols --add-stdcall-alias $(MINGW)/lib/libws2_32.a $(MINGW)/lib/libwinmm.a $(MINGW)/lib/gcc/mingw32/$(MINREL)/libstdc++.a 
INCS     = -I"$(MINGW)/include" -I"../../../src/sys" -I"../../../src/core" -I"../../../src/lib"
CXXINCS  = -I"$(MINGW)/include" -I"../../../src/sys" -I"../../../src/core" -I"../../../src/lib"
OUTPATH  = ../../bin/Legacy/win32/
DLL      = snap7.dll
OUTLIB   = $(OUTPATH)snap7.lib
BIN      = $(OUTPATH)$(DLL)
CXXFLAGS = $(CXXINCS) -DBUILDING_DLL=1 -Ofast -pedantic
CFLAGS   = $(INCS) -DBUILDING_DLL=1
RM       = rm -f

.PHONY: all all-before all-after clean clean-custom

all: all-before $(BIN) all-after

DLLWRAP=dllwrap.exe
DLLTOOL=dlltool.exe
DEFFILE=$(OUTPATH)snap7.def

clean: clean-custom
	${RM} $(OBJ) $(BIN) $(OUTLIB) $(DEFFILE)

$(BIN): $(LINKOBJ)
	$(DLLWRAP) --output-def $(DEFFILE) --driver-name c++ $(LINKOBJ) $(LIBS) -o $(BIN)

$(TEMP)/win32/snap_msgsock.o: ../../../src/sys/snap_msgsock.cpp
	$(CPP) -c ../../../src/sys/snap_msgsock.cpp -o $(TEMP)/win32/snap_msgsock.o $(CXXFLAGS)

$(TEMP)/win32/snap_sysutils.o: ../../../src/sys/snap_sysutils.cpp
	$(CPP) -c ../../../src/sys/snap_sysutils.cpp -o $(TEMP)/win32/snap_sysutils.o $(CXXFLAGS)

$(TEMP)/win32/snap_tcpsrvr.o: ../../../src/sys/snap_tcpsrvr.cpp
	$(CPP) -c ../../../src/sys/snap_tcpsrvr.cpp -o $(TEMP)/win32/snap_tcpsrvr.o $(CXXFLAGS)

$(TEMP)/win32/snap_threads.o: ../../../src/sys/snap_threads.cpp
	$(CPP) -c ../../../src/sys/snap_threads.cpp -o $(TEMP)/win32/snap_threads.o $(CXXFLAGS)

$(TEMP)/win32/s7_client.o: ../../../src/core/s7_client.cpp
	$(CPP) -c ../../../src/core/s7_client.cpp -o $(TEMP)/win32/s7_client.o $(CXXFLAGS)

$(TEMP)/win32/s7_isotcp.o: ../../../src/core/s7_isotcp.cpp
	$(CPP) -c ../../../src/core/s7_isotcp.cpp -o $(TEMP)/win32/s7_isotcp.o $(CXXFLAGS)

$(TEMP)/win32/s7_micro_client.o: ../../../src/core/s7_micro_client.cpp
	$(CPP) -c ../../../src/core/s7_micro_client.cpp -o $(TEMP)/win32/s7_micro_client.o $(CXXFLAGS)

$(TEMP)/win32/s7_partner.o: ../../../src/core/s7_partner.cpp
	$(CPP) -c ../../../src/core/s7_partner.cpp -o $(TEMP)/win32/s7_partner.o $(CXXFLAGS)

$(TEMP)/win32/s7_peer.o: ../../../src/core/s7_peer.cpp
	$(CPP) -c ../../../src/core/s7_peer.cpp -o $(TEMP)/win32/s7_peer.o $(CXXFLAGS)

$(TEMP)/win32/s7_server.o: ../../../src/core/s7_server.cpp
	$(CPP) -c ../../../src/core/s7_server.cpp -o $(TEMP)/win32/s7_server.o $(CXXFLAGS)

$(TEMP)/win32/s7_text.o: ../../../src/core/s7_text.cpp
	$(CPP) -c ../../../src/core/s7_text.cpp -o $(TEMP)/win32/s7_text.o $(CXXFLAGS)

$(TEMP)/win32/snap7_libmain.o: ../../../src/lib/snap7_libmain.cpp
	$(CPP) -c ../../../src/lib/snap7_libmain.cpp -o $(TEMP)/win32/snap7_libmain.o $(CXXFLAGS)
	
all-after:
	$(DLLTOOL) -D $(DLL) -d $(DEFFILE) -l $(OUTLIB)


What I have tried:

#-------------------------------------------------
#
# Project created by QtCreator 2018-01-19T16:14:23
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = C41
TEMPLATE = app

# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as 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_WARNINGS

# You can also make your code fail to compile if you use 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.0


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  += C:\Users\Emrah\Desktop\snap7-full-1.4.2\snap7-full-1.4.2\release\Wrappers\c-cpp
INCLUDEPATH  += C:\Users\Emrah\Desktop\snap7-full-1.4.2\snap7-full-1.4.2\src\core
INCLUDEPATH  +=C:\Users\Emrah\Desktop\snap7-full-1.4.2\snap7-full-1.4.2\src\lib
INCLUDEPATH  +=C:\Users\Emrah\Desktop\snap7-full-1.4.2\snap7-full-1.4.2\src\sys

SOURCES += \
        main.cpp \
        mainwindow.cpp \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/core/s7_client.cpp \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/core/s7_isotcp.cpp \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/core/s7_micro_client.cpp \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/core/s7_partner.cpp \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/core/s7_peer.cpp \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/core/s7_server.cpp \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/core/s7_text.cpp \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/lib/snap7_libmain.cpp \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/sys/snap_msgsock.cpp \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/sys/snap_sysutils.cpp \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/sys/snap_tcpsrvr.cpp \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/sys/snap_threads.cpp \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/release/Wrappers/c-cpp/snap7.cpp \
    dialogdkcs.cpp

HEADERS += \
        mainwindow.h \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/core/s7_client.h \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/core/s7_firmware.h \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/core/s7_isotcp.h \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/core/s7_micro_client.h \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/core/s7_partner.h \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/core/s7_peer.h \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/core/s7_server.h \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/core/s7_text.h \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/core/s7_types.h \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/lib/snap7_libmain.h \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/sys/snap_msgsock.h \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/sys/snap_platform.h \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/sys/snap_sysutils.h \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/sys/snap_tcpsrvr.h \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/sys/snap_threads.h \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/sys/sol_threads.h \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/sys/unix_threads.h \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/src/sys/win_threads.h \
    ../../snap7-full-1.4.2/snap7-full-1.4.2/release/Wrappers/c-cpp/snap7.h \
    dialogdkcs.h

FORMS += \
        mainwindow.ui \
    dialogdkcs.ui

RESOURCES += \
    picture.qrc
Posted
Updated 9-Jul-18 21:19pm

See GNU make[^].

However, the shown Makefile will create the snap7.dll and snap7.lib. If you have executed that using make all, there is no need to compile the source files (snap_*.cpp) again in your Qt project. Instead just add the library to your Qt project with the correct path:
win32:LIBS += <snap7_make_output_path>/snap7.lib
and remove the snap7 source and header files.
 
Share this answer
 
Comments
Emrah Duatepe 10-Jul-18 3:29am    
OK,I will
Make is a very well established (I would say ancient) tool and, while makefile syntax is admittedly awkward, it is very well documented. So read the manuals or some of the freely available tutorials.
 
Share this answer
 
Comments
Emrah Duatepe 10-Jul-18 3:28am    
Thank you for information,
"So read the manuals or some of the freely available tutorials" what that sentence does mean?
CPallini 10-Jul-18 3:36am    
It means: "so read the manuals or some of the freely available tutorials".
Emrah Duatepe 10-Jul-18 3:37am    
really,probably ,you musnt write a command for everyone's health
CPallini 10-Jul-18 4:06am    
I am very sorry your health was hurt.
Emrah Duatepe 10-Jul-18 3:40am    
This one is usefull comment.Not yours.

See GNU make[^].

However, the shown Makefile will create the snap7.dll and snap7.lib. If you have executed that using make all, there is no need to compile the source files (snap_*.cpp) again in your Qt project. Instead just add the library to your Qt project with the correct path:
Hide Copy Code
win32:LIBS += <snap7_make_output_path>/snap7.lib
and remove the snap7 source and header files.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900