[SOLVED] boost libraries in Qt: the proper way to install them and why do I have problems?
-
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 += coreQT -= gui
TARGET = testQt
CONFIG += console
CONFIG -= app_bundleTEMPLATE = 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!
-
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@ -
SGaist. Thank you.
[code]
QT += coreQT -= gui
TARGET = testQt
CONFIG += console
CONFIG -= app_bundleTEMPLATE = 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!
-
The extension should not be used in this case and also no prefix
@LIBS += -lboost_regex@
-
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!
-
clang and gcc are binary compatible on OS X
You still have the -l part wrong, read again my last post
-
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!
-
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
@