[resolved] adding boost libraries to paths...?



  • I did a search in the forum, but couldn't find an answer.

    I may need to begin using boost. When I installed it, I got this message at the end:
    @ The following directory should be added to compiler include paths:

    /usr/local/boost_1_48_0
    

    The following directory should be added to linker library paths:

    /usr/local/boost_1_48_0/stage/lib@
    

    So...do I need to do something in my Creator preferences/build settings to reflect this, or should these simply be added to Unix environment variables? (And if the latter, can someone tell me which ones?) This is on a Mac, by the way.

    Thanks...



  • In .pro file you have to add this:
    http://doc.qt.nokia.com/latest/qmake-variable-reference.html#includepath
    @
    INCLUDEPATH += /usr/local/boost_1_48_0
    @
    http://doc.qt.nokia.com/latest/qmake-variable-reference.html#libs
    @
    LIBS += -L/usr/local/boost_1_48_0/stage/lib
    @
    This should work.



  • Thank you, Hostel. Do you happen to know if there's a way to put those in the preferences, or otherwise automate their inclusion when a new project is created? That would be very convenient.



  • I don't know how do this but I found something: if you using g++ you could use environment variables:
    http://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html
    but then if you will use some lib then you still have to add a option for linker - something like this(SDL example):
    @
    LIBS += -lSDL //flag, not directory because in env is added a directory
    @
    So you can skip from using a INCLUDEPATH in .pro file and a /long/path/directory in LIBS but you have to still use lib flags in LIBS(as above).



  • What I did, was create my own boost.prf file in <QtDir>/mkspecs/features

    That allows me to just do this in my .pro file:
    @
    CONFIG += boost
    @

    And everything just works.

    The .prf file is basically a part of a .pro file that contains stuff for paths and libraries to link against.



  • [quote author="Andre" date="1322039547"]What I did, was create my own boost.prf file in <QtDir>/mkspecs/features [/quote]

    Do you mind dumping it on the wiki? It could be very handy for our fellow developers.



  • Andre -

    Exactly what did you put in the boost.prf file?

    And, am I correct in assuming you're talking about your equivalent to this directory on my system?

    Developer/Applications/Qt/Desktop/Qt/474/gcc/mkspecs

    Thanks...



  • Hi
    Please check this
    "Adding Libraries to Projects":http:////qt-project.org/doc/qtcreator-2.5/creator-project-creating.html
    Add BOOST as external liberary to your project. Following line will be added in .pro file of your project. I am using Linux

    @unix:!macx:!symbian: LIBS += -L$$PWD/../../../../../usr/local/lib/ -lboost_chrono

    INCLUDEPATH += $$PWD/../../../../../usr/local/include
    DEPENDPATH += $$PWD/../../../../../usr/local/include

    unix:!macx:!symbian: PRE_TARGETDEPS += $$PWD/../../../../../usr/local/lib/libboost_chrono.a

    unix:!macx:!symbian: LIBS += -L$$PWD/../../../../../usr/local/lib/ -lboost_context

    INCLUDEPATH += $$PWD/../../../../../usr/local/include
    DEPENDPATH += $$PWD/../../../../../usr/local/include

    unix:!macx:!symbian: PRE_TARGETDEPS += $$PWD/../../../../../usr/local/lib/libboost_context.a
    @

    Thanks



  • Hi
    Sorry in the above post the link is wrong
    Please check this
    "Adding Libraries to Projects":http://qt-project.org/doc/qtcreator-2.6/creator-project-qmake-libraries.html
    Add BOOST as external library to your project. Following line will be added in .pro file of your project. I am using Linux

    @unix:!macx:!symbian: LIBS += -L$$PWD/../../../../../usr/local/lib/ -lboost_chrono

    INCLUDEPATH += $$PWD/../../../../../usr/local/include
    DEPENDPATH += $$PWD/../../../../../usr/local/include

    unix:!macx:!symbian: PRE_TARGETDEPS += $$PWD/../../../../../usr/local/lib/libboost_chrono.a

    unix:!macx:!symbian: LIBS += -L$$PWD/../../../../../usr/local/lib/ -lboost_context

    INCLUDEPATH += $$PWD/../../../../../usr/local/include
    DEPENDPATH += $$PWD/../../../../../usr/local/include

    unix:!macx:!symbian: PRE_TARGETDEPS += $$PWD/../../../../../usr/local/lib/libboost_context.a
    @

    Thanks



  • Hi
    I have downloaded example files from this link
    "example Days Alive: qtBoostExample.zip":http://cpp-qt-mac-win.blogspot.in/2011/10/qt-boost-for-beginners-step-by-step.html
    And add the external lib as
    @unix:!macx:!symbian: LIBS += -L$$PWD/../../../../../usr/local/lib/ -lboost_date_time
    INCLUDEPATH += $$PWD/../../../../../usr/local/include
    DEPENDPATH += $$PWD/../../../../../usr/local/include
    unix:!macx:!symbian: PRE_TARGETDEPS += $$PWD/../../../../../usr/local/lib/libboost_date_time.a@
    Its working fine
    Thanks
    Manoj


Log in to reply
 

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