Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] boost libraries in Qt: the proper way to install them and why do I have problems?

[SOLVED] boost libraries in Qt: the proper way to install them and why do I have problems?

Scheduled Pinned Locked Moved General and Desktop
9 Posts 2 Posters 3.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    igorland
    wrote on last edited by
    #1

    Hello. For the first time, I am trying to install boost library into Qt on Mac (10.9.4) and I am completely confused. This is what I did:

    I installed boost using homebrew.

    I see that hpp files are installed here:

    [code]
    /usr/local/Cellar/boost/1.55.0_2/include/boost
    [/code]

    and libraries here:

    [code]
    /usr/local/Cellar/boost/1.55.0_2/lib
    [/code]

    Now I start a new Qt console project.

    the project file:

    [code]
    QT += core

    QT -= gui

    TARGET = testQt
    CONFIG += console
    CONFIG -= app_bundle

    TEMPLATE = app

    SOURCES += main.cpp

    INCLUDEPATH += /usr/local/Cellar/boost/1.55.0_2
    [/code]

    And the main file:

    [code]
    #include <QCoreApplication>
    #include <QtCore>
    #include <iostream>
    #include <QDebug>

    #include <boost/regex.hpp>

    using namespace std;

    int main(int argc, char *argv[])
    {
    QCoreApplication a(argc, argv);

    std::string line;
    boost::regex pat( "^Subject: (Re: |Aw: )(.)" );

    while (std::cin)
    {
    std::getline(std::cin, line);
    boost::smatch matches;
    if (boost::regex_match(line, matches, pat))
    std::cout << matches[2] << std::endl;
    }
    return a.exec();
    }
    [/code]

    It is not compiling. Issues:

    [code]
    Symbol(s) not found for architectures x86_64
    linker command failed with exist code 1
    [/code]

    Since I am absolutely noob with boost, did I do it right? If yes, why is it not compiling?
    I've read that this may be because boost libraries are built as 32-bit and not 64-bit, but I thought that homebrew would take care of that.

    Thanks a lot!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You are not linking to the boost libraries.

      @LIBS +=
      -L/usr/local/Cellar/boost/1.55.0_2/lib
      -lname_of_boost_library_you_are_using@

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • I Offline
        I Offline
        igorland
        wrote on last edited by
        #3

        SGaist. Thank you.

        [code]
        QT += core

        QT -= gui

        TARGET = testQt
        CONFIG += console
        CONFIG -= app_bundle

        TEMPLATE = app

        SOURCES += main.cpp

        INCLUDEPATH += /usr/local/Cellar/boost/1.55.0_2

        LIBS +=
        -L/usr/local/Cellar/boost/1.55.0_2/lib
        -llibboost_regex.a
        [/code]

        Error:

        @library not found for -llibboost_regex.a@

        Same happens with dylib. Is it possible that Qt has no access to use/local?

        If I just leave it as

        @LIBS +=
        -L/usr/local/Cellar/boost/1.55.0_2/lib@

        Same issue with architectures x86_64...

        Thank you!

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          The extension should not be used in this case and also no prefix

          @LIBS += -lboost_regex@

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • I Offline
            I Offline
            igorland
            wrote on last edited by
            #5

            Nope. Still not working...

            https://www.dropbox.com/s/j9f2zjiepmref4y/screen2.png

            https://www.dropbox.com/s/z3leuvpklutr1jd/screen5.png

            https://www.dropbox.com/s/ipubgzneyw3kyma/screen3.png

            Is it possible that my boost library is not compiled correctly for clang? I see it says libc++.

            https://www.dropbox.com/s/kvq0vz1qq919agi/screen1.png

            But if so, what would be the proper way to compile? I have tried several examples, including the one above and then it would apparently fail.

            Thank you!

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              clang and gcc are binary compatible on OS X

              You still have the -l part wrong, read again my last post

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • I Offline
                I Offline
                igorland
                wrote on last edited by
                #7

                SGaist. Thanks for bearing with me:

                I hope you meant this:

                https://www.dropbox.com/s/gttsooefs1ah7tq/screen6.png

                Because putting just @LIBS += -lboost_regex@ without a path gives library not found error.

                Thank you!

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  You still need to give the path to find your libraries files

                  @
                  LIBS +=
                  -L/usr/local/Cellar/boost/1.55.0_2/lib
                  -lboost_regex
                  @

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • I Offline
                    I Offline
                    igorland
                    wrote on last edited by
                    #9

                    SGaist. Thank you so much. Inserting the path as you suggested and inserting this:
                    @CONFIG += c++11@
                    into the project file worked. I really appreciate your support! Thank you!

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved