Right way to include files from an external project?
-
Hello everybody,
I would like to include a C++ project into my Qt project; I created a subdirectory for content all data with a .pri inside.
here is the tree from my project:
drawRange+ +drawRange.pro +main.cpp +---->drawRangeGUI (here ist my Qt MainWindow) + +---->hmisg+ +hmisg.pri (the pri for my subproject) +hmisg.cpp +---->erpc-1.7.1+ +---->erpc_c+ +---->config <--- In each subdirectory here +---->infra <--- are many files +---->port <--- that I want +---->setup <--- for my +---->transports <--- project
I created the .pri, first manually, after from Qt Creator with "(right mouse button in the project)-->Add Existing Files"
Here is my drawRange.pro
QT += core gui charts greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = drawRange TEMPLATE = app include(drawRangeGUI/drawRangeGUI.pri) include(hmisg/hmisg.pri) DEFINES += QT_DEPRECATED_WARNINGS CONFIG += c++11 SOURCES += \ main.cpp HEADERS += FORMS += \ # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target DISTFILES += \ drawRangeGUI/drawrange.pri
and my hmisg.pri.pri
INCLUDEPATH += $$PWD \ $$PWD/erpc-1.7.1/erpc_c/port \ $$PWD/erpc-1.7.1/erpc_c/infra \ $$PWD/erpc-1.7.1/erpc_c/setup \ $$PWD/erpc-1.7.1/erpc_c/config \ $$PWD/erpc-1.7.1/erpc_c/transports DEPENDPATH += $$PWD \ $$PWD/erpc-1.7.1/erpc_c/port \ $$PWD/erpc-1.7.1/erpc_c/infra \ $$PWD/erpc-1.7.1/erpc_c/setup \ $$PWD/erpc-1.7.1/erpc_c/config \ $$PWD/erpc-1.7.1/erpc_c/transports HEADERS += \ $$PWD/hmisg.h \ $$PWD/erpc-1.7.1/erpc_c/setup/erpc_server_setup.h \ $$PWD/erpc-1.7.1/erpc_c/setup/erpc_client_setup.h \ $$PWD/erpc-1.7.1/erpc_c/infra/erpc_basic_codec.h \ $$PWD/erpc-1.7.1/erpc_c/infra/erpc_client_manager.h \ $$PWD/erpc-1.7.1/erpc_c/infra/erpc_codec.h \ $$PWD/erpc-1.7.1/erpc_c/infra/erpc_common.h \ $$PWD/erpc-1.7.1/erpc_c/infra/erpc_crc16.h \ $$PWD/erpc-1.7.1/erpc_c/infra/erpc_framed_transport.h \ $$PWD/erpc-1.7.1/erpc_c/infra/erpc_manually_constructed.h \ $$PWD/erpc-1.7.1/erpc_c/infra/erpc_message_buffer.h \ $$PWD/erpc-1.7.1/erpc_c/infra/erpc_server.h \ $$PWD/erpc-1.7.1/erpc_c/infra/erpc_simple_server.h \ $$PWD/erpc-1.7.1/erpc_c/infra/erpc_transport.h \ $$PWD/erpc-1.7.1/erpc_c/infra/erpc_version.h \ $$PWD/erpc-1.7.1/erpc_c/setup/erpc_mbf_setup.h \ $$PWD/erpc-1.7.1/erpc_c/setup/erpc_transport_setup.h \ $$PWD/erpc-1.7.1/erpc_c/config/erpc_config.h \ $$PWD/erpc-1.7.1/erpc_c/port/erpc_config_internal.h \ $$PWD/erpc-1.7.1/erpc_c/port/erpc_port.h \ $$PWD/erpc-1.7.1/erpc_c/port/erpc_threading.h \ $$PWD/erpc-1.7.1/erpc_c/transports/erpc_tcp_transport_win.h SOURCES += \ $$PWD/hmisg.cpp \ $$PWD/erpc-1.7.1/erpc_c/setup/erpc_server_setup.cpp \ $$PWD/erpc-1.7.1/erpc_c/setup/erpc_client_setup.cpp \ $$PWD/erpc-1.7.1/erpc_c/infra/erpc_basic_codec.cpp \ $$PWD/erpc-1.7.1/erpc_c/infra/erpc_client_manager.cpp \ $$PWD/erpc-1.7.1/erpc_c/infra/erpc_crc16.cpp \ $$PWD/erpc-1.7.1/erpc_c/infra/erpc_framed_transport.cpp \ $$PWD/erpc-1.7.1/erpc_c/infra/erpc_message_buffer.cpp \ $$PWD/erpc-1.7.1/erpc_c/infra/erpc_server.cpp \ $$PWD/erpc-1.7.1/erpc_c/infra/erpc_simple_server.cpp \ $$PWD/erpc-1.7.1/erpc_c/setup/erpc_setup_mbf_dynamic.cpp \ $$PWD/erpc-1.7.1/erpc_c/setup/erpc_setup_tcp.cpp \ $$PWD/erpc-1.7.1/erpc_c/port/erpc_threading_windows.cpp \ $$PWD/erpc-1.7.1/erpc_c/transports/erpc_tcp_transport_win.cpp
But after compile, I obtained 86 errors of a project that did work in Visual Studio. it seems to have to do with the inclusion of <Windows.h>, <winsock2.h>, <ws2tcpip.h> and others among the files, because when I comment in a File <winsock2.h> and <ws2tcpip.h>, the number of errors falls to 24, but I get fails like
D:\@Qt_Projects\drawRange\hmisg\erpc-1.7.1\erpc_c\transports\erpc_tcp_transport_win.cpp:159: error: C2079: 'hints' uses undefined struct 'erpc::TCPTransport::connectClient::addrinfo'
for the next line:
struct addrinfo hints = { 0 };
with a little patience, I discovered that the structure is defined in <ws2def.h> like
typedef struct addrinfo { int ai_flags; // AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST int ai_family; // PF_xxx int ai_socktype; // SOCK_xxx int ai_protocol; // 0 or IPPROTO_xxx for IPv4 and IPv6 size_t ai_addrlen; // Length of ai_addr char * ai_canonname; // Canonical name for nodename _Field_size_bytes_(ai_addrlen) struct sockaddr * ai_addr; // Binary address struct addrinfo * ai_next; // Next structure in linked list } ADDRINFOA, *PADDRINFOA;
Is my way the right to include the files? Why I get this issues in a project that compile in other tool?
please, any help will be welcomed.
Thanks in advance