Include files in Qt ,the location of libraries



  • Hi,
    I am new to Qt and am trying to learn from an open source project called qt-box-editor.When I open the project in Qt creator i find that includes like the following

    @
    #include <leptonica/allheaders.h>
    @

    are underlined meaning that something is wrong.These are libraries that the project uses,one is leptonica and the other is tesseract.I know I can go and copy the headers from the libraries one by one in my project but I want to learn the proper way to do this.

    My .pro file refers to them like this:
    @
    LIBS += -llept -ltesseract
    @

    To wrap up my problem is this :where can I put those libraries to make my project compile normally.And just to be sure,these are static libraries,right?
    Sorry if I ask stupid questions as I am trying to find my way into this.
    Thanks.
    Edit:I am using Windows 7,32bit, vs2010 and Qt 4.8.1 Qt Creator 2.4.1


  • Moderators

    welcome to devnet

    The .pro files are input files for qmake. The "qmake syntax":http://qt-project.org/doc/qt-4.8/qmake-project-files.html may be found here. Also Qt creator is reading the .pro file and shares the syntax.

    The "LIBS":http://qt-project.org/doc/qt-5.0/qtdoc/qmake-variable-reference.html#libs parameter is for the libraries, while you need to use the "INCLUDEPATH":http:// for the include path.



  • Thanks,
    just to be clear,I use

    @
    #include "-----------------------------"
    @

    when the header file is in some directory and use

    @
    #include <----------------------------->
    @

    when the header file is encapsulated in a library.What should I do to be able to use the second syntax and compile without getting those underline errors.
    Thanks.


  • Moderators

    [quote author="QSamBok" date="1371538683"]Thanks,
    just to be clear,I use

    @
    #include "-----------------------------"
    @

    when the header file is in some directory and use

    @
    #include <----------------------------->
    @

    when the header file is encapsulated in a library.What should I do to be able to use the second syntax and compile without getting those underline errors.
    Thanks.
    [/quote]
    Those are the include declarations in the source code. The include files for libraries are typically on separate directories as you note. Qt creator needs to know where to find these includes, as the compiler has to know as well. The qmake LIBS is for libraries as you already found out, but it is only affecting the linking step, not the compilation of your source code.
    For compilation your compiler has to know where the includes are found and also has Qt creator to know where to find your includes.
    Therefore, you have to add in the INCLUDEPATH the folders/directories with the include files. The path may be completely identical to the one you are passing to LIBS, but you have to declare separately.


Log in to reply
 

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