Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use the Boost libraries in a qmake project?

Tags:

c++

boost

qt

Some days ago I compiled Boost ver. 1.53.0 for VS2012. It works fine, compiles fine. Now I want to use Boost with Qt Creator. In the .pro file I've included

INCLUDEPATH += C:\boost\boost_1_53_0\  -lboost_filesystem
LIBS += C:/boost/boost_1_53_0/stage/lib/

But when I compile I get 2 errors:

:-1: error: cannot find C:/boost/boost_1_53_0/stage/lib/: Permission denied
collect2.exe:-1: error: error: ld returned 1 exit status

What should I do? I've googled but seems I'm the first with this error.

like image 750
ddacot Avatar asked Jun 08 '13 10:06

ddacot


People also ask

How to add new libraries in Qt Creator?

If the library name ends in d, deselect the Remove "d" suffix for release version option. Qt Creator supports code completion and syntax highlighting for the added libraries once your project successfully builds and links to them. In the Projects view, right-click the project name to open the context menu and select Add Library.

Do you use boost in Qt?

I don't use boost as much as I could, often I already have an alternative in Qt (filesystem e.g.). Where boost really comes to shine is, that it is essentially a toolbox, full of helpful little libraries, plus a few big libraries handling things like parsing, filesystem, sockets, threading or GPU computing.

Is there a new generation of Boost libraries?

There is now the boost incubator, making it easier to submit libraries to boost. There is a new generation of boost libraries build with C++11 and C++14, though boost probably will have a few legacy libraries, which will or already have found their replacements. For example boost::tmp -> boost::hana.

How to get the include path of a library in Qt?

You can use pkg-config to query system libraries during compilation. For your own libraries and 3rd party libraries, you need to specify the paths. Qt Creator tries to guess the include path for an external library, but you need to check it and modify it if necessary.


1 Answers

INCLUDEPATH += C:\boost\boost_1_53_0\  -lboost_filesystem
LIBS += C:/boost/boost_1_53_0/stage/lib/

Wrong.

Read this.

Solution:

INCLUDEPATH += C:/boost/boost_1_53_0/
LIBS += "-LC:/boost/boost_1_53_0/stage/lib/"

Boost has complicated library names ("libboost_filesystem-vc90-mt-1_53.lib") and in case of msvc it links them automatically.) If you want to link additional lib, you do it like this:

LIBS += "-LMyLibraryPath" -lmylib

Where MyLibraryPath is library path, and mylib is library you want to link with.

i'm the first with this error.

The error most likely occurs because compiler tries to open directory as if it were a file or something like that.

like image 69
SigTerm Avatar answered Sep 30 '22 09:09

SigTerm