Sources involved in connection activity are include in the omconnector
directory of the OPENMAIA connector C++ folder.
You can copy all the omconnector
directory into your source tree.
In order to define classes involved in the connection activity, headers files must be included into sources.
omconnector.h
provide automatic inclusion of all files needed to use the library, so in your source code you have to include this header, for example:
#include "omconnector/omconnector.h"
The next step require to tell to the GCC compiler to insert source files of the OPENMAIA C++ connection library. Those files are:
omconnector/connector.cpp omconnector/message.cpp omconnector/tcp_parser.cpp
Those files use POSIX threads, so is necessary to tell to the linker to include pthread
system library with the command -lpthread
.
If you use Makefile you can use this example:
CPP = g++ CPPFLAGS = -g LDFLAGS = -lpthread # All developed programs PROGRAMS = myprogram OBJECTS = myprogram_main.o \ myobject_1.o \ <...> myprogram_N.o HEADERS = myheader_1.h \ <...> myheader_M.h OM_LIBRARY = omconnector/connector.o \ omconnector/message.o \ omconnector/tcp_parser.o OM_HEADERS= omconnector/omconnector.h \ omconnector/connector.h \ omconnector/message.h \ omconnector/tcp_parser.h .SUFFIXES: .o .cpp .cpp.o : $(CXX) -c $(CPPFLAGS) -o $@ $< all: $(PROGRAMS) myprogram: $(OBJECTS) $(HEADERS) $(OM_LIBRARY) $(OM_HEADERS) $(CXX) -o myprogram $(OBJECTS) $(OM_LIBRARY) $(LDFLAGS)