Adding a project to an existing project [solved]



  • Hi,

    I am new to Qt, so sorry if the question has been asked before (I couldn't find my answer).

    I have a project, containing 2 git sub-modules (sub-module A & B).
    Each of these sub-modules contain several other sub-modules ( Let's say A contains a, b ,c ,d & B contains a, b, c , e. A & B share some sub-modules).

    I added the sub-module A successfully and complied and ran my project. When I added the second sub-module, I got bunch of errors.

    I have the following problem:

    As A & B are sharing some same sub-modules ( a, b & c) and the sub-module's libraries are included in the header files, I get lots of errors mentioning repetitive definition of the same variables. In this case, I have my own project, sub-module A, and sub-module B. Is there any way to compile A & B independently inside my main project to prevent these kind of confusions?

    I don't want to change any of those sub-modules (A&B). I only can change my own project which uses A & B.

    Thanks


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    How are you currently building your project ? What's your pro file setup ?



  • Thanks

    I am building it using the hammer icon :)

    Here is my .pro file
    @
    QT += core gui

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport

    TARGET = GoLINC-esstest
    TEMPLATE = app
    CONFIG += debug
    DESTDIR = bin
    OBJECTS_DIR = build
    MOC_DIR = build
    UI_DIR = build

    QMAKE_CXXFLAGS = -std=c++0x

    #To be included in all future ESS projects
    include(esstestframework/essTestFramework.pri)

    INCLUDEPATH +=
    src/
    jbx7000-module-test/DCSupply/src/
    jbx7000-module-test/serialIPMI/src/
    curl-library/ \

    SOURCES +=
    src/main.cpp
    src/version.h \ #header file autogenerated by verGen at bottom
    src/golincrootmodule.cpp
    src/vlanConfig.cpp
    src/golincappmodule.cpp
    src/golincacc.cpp
    src/golinc_smm.cpp
    src/golinc_wcm.cpp
    src/golinc_psm.cpp
    curl-library/curlClass.cpp
    src/genericfunctions.cpp
    jbx7000-module-test/serialIPMI/IPMILib/ipmi_smm.c
    jbx7000-module-test/serialIPMI/IPMILib/smm_ipmi_cmds.c
    jbx7000-module-test/serialIPMI/IPMILib/ipmb.c
    jbx7000-module-test/src/SMMTest.cpp
    jbx7000-module-test/serialIPMI/src/serialIPMI.cpp
    jbx7000-module-test/serialIPMI/src/sendIPMI.cpp
    jbx7000-module-test/serialIPMI/IPMILib/smm_ipmi_cmds.c
    jbx7000-module-test/serialIPMI/IPMILib/ipmi_smm.c
    jbx7000-module-test/serialIPMI/IPMILib/flash_info.c
    jbx7000-module-test/serialIPMI/IPMILib/ipmb.c
    jbx7000-module-test/DCSupply/src/DCSupply.cpp

    HEADERS +=
    src/golincrootmodule.h
    src/vlanConfig.h
    src/golincappmodule.h
    src/golincacc.h
    src/golinc_smm.h
    src/golinc_wcm.h
    src/golinc_psm.h
    curl-library/curlClass.h
    src/genericfunctions.h
    jbx7000-module-test/serialIPMI/IPMILib/ipmi_smm.h
    jbx7000-module-test/serialIPMI/IPMILib/smm_ipmi_cmd.h
    jbx7000-module-test/serialIPMI/IPMILib/smm_ipmi_cmds.h
    jbx7000-module-test/IserialIPMI/PMILib/iders_jbx7000_def.h
    jbx7000-module-test/serialIPMI/IPMILib/ipmb.h
    jbx7000-module-test/serialIPMI/IPMILib/ipmi-cmd-oem-common-spec.h
    jbx7000-module-test/serialIPMI/IPMILib/ipmi-cmd-oem-iders-spec.h
    jbx7000-module-test/serialIPMI/IPMILib/ipmi-netfn-spec.h
    jbx7000-module-test/GUI/splitString.h
    jbx7000-module-test/src/version.h
    jbx7000-module-test/src/SMMTest.h
    jbx7000-module-test/serialIPMI/src/serialIPMI.h
    jbx7000-module-test/serialIPMI/IPMILib/smm_ipmi_cmds.h
    jbx7000-module-test/serialIPMI/IPMILib/smm_ipmi_cmds_packed.h
    jbx7000-module-test/serialIPMI/IPMILib/smm_ipmi_cmd.h
    jbx7000-module-test/serialIPMI/IPMILib/flash_address_info.h
    jbx7000-module-test/serialIPMI/IPMILib/flash_info.h
    jbx7000-module-test/serialIPMI/IPMILib/iders_jbx7000_def.h
    jbx7000-module-test/serialIPMI/IPMILib/ipmb.h
    jbx7000-module-test/serialIPMI/IPMILib/ipmi_smm.h
    jbx7000-module-test/serialIPMI/IPMILib/ipmi-cmd-oem-common-spec.h
    jbx7000-module-test/serialIPMI/IPMILib/ipmi-cmd-oem-iders-spec.h
    jbx7000-module-test/serialIPMI/IPMILib/ipmi-netfn-spec.h
    jbx7000-module-test/DCSupply/src/DCSupply.h

    OTHER_FILES +=
    bin/config.txt
    bin/emails.txt
    bin/envConfig.txt
    bin/GoLINCTestConfig.txt
    jbx7000-module-test/serialIPMI/IPMILib/Makefile

    add the targets the list of extra targets

    QMAKE_EXTRA_TARGETS +=
    genVersion \

    copyModuleConfig \

    PRE_TARGETDEPS +=
    genVersion \

    copyModuleConfig \

    LIBS +=
    -lssh
    -lxml2
    -lcurl
    -lpcap
    -ltar
    -lsnmp
    -lreadline
    -L/usr/lib -lhidapi-libusb
    -lxml2 \

    Copying PTC3 module test config files to bin dir

    copyModuleConfig.target =
    copyModuleConfig.commands =
    echo "Copying PTC3 module test config files to bin dir";
    cp /jbx7000-module-test/bin/SMMconfig.txt /bin/SMMconfig.txt; \

    cp jbx7000-module-test/bin/SEAPMconfig.txt bin/SEAPMconfig.txt; \

    #cp jbx7000-module-test/bin/WCM2config.txt bin/WCM2config.txt; \
    #cp jbx7000-module-test/bin/PSMconfig.txt bin/SEAPMconfig.txt; \
    

    copyModuleConfig.depends =

    ########################## Start of genVersion ##########################

    auto generate the src/version.h file every time we build

    ** for new projects - copy this code into new .pro file and

    ** versionGenerator.h from esstestframework project into

    ** new project dir

    ** >git tag -a vx.x.x to set and increment version

    #########################################################################

    create a new build target

    genVersion.target =
    genVersion.commands =
    echo "Generating version header file";
    ./versionGenerator.sh;
    genVersion.depends =

    ########################## End of genVersion #############################
    @

    /jbx7000-module-tes is one of my sub-modules (Sub-module B)


  • Lifetime Qt Champion

    What I meant was: are you building them as sub projects or including their content in your main project. Looks like solution number 2.

    Are the common files of these two sub-modules the same ?



  • It is number 2, I am including their content in my main project.
    They have common files and I think that causes the errors.
    How can I build them as sub projects?


  • Lifetime Qt Champion

    If these files are exactly the same, then only use them once in your pro file.

    Otherwise have a look at the qmake manual to see how you can do that with the subdirs template



  • Thanks SGaist.
    I fixed the issue by editing the pro file.


  • Lifetime Qt Champion

    You're welcome !

    Since you have it building now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.