Significance of the following code



  • Hi All,

    I have a code which have different directories. In each directory a library file is added. Can anyone please tell me what is the significance of this code which is made as a library. if I remove this library from each directory and main then code does not get executed and gives error as :

    (.text+0x18):-1: error: undefined reference to `main'

    :-1: error: collect2: ld returned 1 exit status

    @
    ######################

    common stuff for all components

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

    TEMPLATE = lib

    CONFIG += static
    warn_on
    qt
    thread
    rtti

    QT += core
    gui

    INCLUDEPATH +=/..
    ../../MultiFuncTester/Components \

    DEPENDPATH +=/..
    ../../MultiFuncTester/Components \

    CONFIG += debug_and_release
    CONFIG += build_all

    QMAKE_CXXFLAGS += -Wall

    CONFIG(debug, debug|release) {
    CONFIG_SUFFIX = dbg
    } else {
    CONFIG_SUFFIX = rel
    DEFINES += QT_NO_DEBUG
    QT_NO_DEBUG_OUTPUT
    DBT_TRACE_DISCARD
    NDEBUG
    CONFIG(gcov) {
    QMAKE_CXXFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
    QMAKE_LFLAGS_RELEASE += -fprofile-arcs
    QMAKE_CXXFLAGS_RELEASE -= -O2
    QMAKE_CXXFLAGS_RELEASE += -O0
    }
    }

    CONFIG(crosstgt) {

    To be able to build Target run qmake as follows:

    #qmake CONFIG+=crosstgt
    CONFIG_SUFFIX = $${CONFIG_SUFFIX}_tgt
    DEFINES += TARGET_BUILD
    }

    OBJECTS_DIR = obj_$${CONFIG_SUFFIX}
    MOC_DIR = moc_$${CONFIG_SUFFIX}
    DESTDIR = lib_$${CONFIG_SUFFIX}

    ######################
    @

    Thanks in advance



  • Your linker is telling you that, in all the components you have given the linker to work with, it is unable to find your program's main() function.

    I don't know what you expected us to do with the PRO file extract you posted.



  • i want to know what do you understand as you read this code. Is it telling something about makefile configurations



  • bq. Is it telling something about makefile configurations

    Yes. It is part of a Qt project definition. It (partially) instructs qmake how to write a Makefile to build the project. If this is the "library" (it is not a library) that you removed from each directory on a complete project then chances are the project is completely broken now. In an age-old tradition you get to keep the pieces.



  • TEMPLATE = lib

    doesn't it define it as library?

    As I told earlier it is been added to each of the sub directory, does this code relates each sub dir with main ??

    [quote author="ChrisW67" date="1338271480"]bq. Is it telling something about makefile configurations

    Yes. It is part of a Qt project definition. It (partially) instructs qmake how to write a Makefile to build the project. If this is the "library" (it is not a library) that you removed from each directory on a complete project then chances are the project is completely broken now. In an age-old tradition you get to keep the pieces.
    [/quote]

    Can you tell me how and in which line it explains.....

    It will be very grateful if you help me to understand this code....

    I need to understand wether i should keep this or not?



  • The file you have posted is not a library. The file you have posted describes, partially, a project to qmake. That project would, if it were complete, result in a static library being built: that's what "TEMPLATE = lib" with "CONFIG += static" means. See "qmake Common Projects" in the QMake Manual.

    If you remove the "TEMPLATE = lib" line then qmake will default to making a standalone application. Building using the resulting Makefile will almost certainly fail because the library almost certainly does not have a main() function.

    The library this project would produce may be used by another project. You could only tell by looking at that other project.



  • [quote author="ChrisW67" date="1338272542"]

    The library this project would produce may be used by another project. You could only tell by looking at that other project.[/quote]

    didnt understand this....

    What the line 43-54 describes here??



  • bq. didnt understand this….

    This project file could be used to build a library.
    That library can be used by other projects.
    You cannot tell from this project what other projects might be using it.
    You need to look at the other projects to see if they use the library that this project builds.

    bq. What the line 43-54 describes here??

    Some extra variables that are set of the CONFIG variable contains the word "crosstgt". There is no information about what "Target" is. I could "guess":http://dictionary.reference.com/browse/guess that this is related in some way to cross-compiling the project.



  • So till now what I got from this discussion is that since I am making my project as sub dirs, it is better to use this file as a common setting as it contains configurations for qmake which shall be common for all the subdirectories.

    Am I correct?



  • I cannot possibly know if these settings are common to all or part of the subdirectories in your project. It is your project; you dictate how it is built.

    The fragment probably only makes sense if used from a directory where there exists a directory ../../MultiFuncTester/Components (that is two levels up and across)



  • Yeah Chris u were right....I gave some time to makefile (guess knew very little about it) had to made some very minute changes...now its working absolutely fine...Thank you so much for your help....
    Looking forward for same ......:)


Log in to reply
 

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