How to install Boost library? How to add library to project?
-
@aret777 OK, that's because you added the library (the .so/.a) file, but you didn't add an entry for the header files.
I have to log off now (Christmas dinner!), but I'll try to check in later. Another entry to your .pro file should get you there.
-
@aret777 sorry I wasn't clear. From what I can se, you need to do the following:
- remove the 2nd LIBS line
- remove whatever line is causing your Boost project file to show up.
- Add a line like this:
INCLUDEPATH += /home/user/Documents/BoostLibrary
-
@mzimmers
like this? I compile, nothing changes
Or, maybe... I dont need to add .hpp file to include library to project? But I tried now to include .so and .a files - no effect...
Edit: I found the way to include .hpp files! But it gaves other errors...
-
No, something's still wrong with your .pro file.
You need to get rid of that entry for the BoostLinkingTest.pro file.EDIT:
disregard that last line.May I see the complete contents of your .pro file?
-
My bad...I gave you bad advice on the LIBS entry. You need to specify the full path to the library you want to use. There may be a way to wildcard that; I'll do some looking. In the meantime, if you know specifically which boost libraries you need, modify your LIBS entry to contain the full path to those libraries.
EDIT:
Look at the LIBS entry on this page for how to explicitly add libraries to your project.
-
@mzimmers Okay, if it will work, its fine.
But what file I need then to add to LIBS?
LIBS += /home/user/Documents/BoostLibrary/stage/lib/libboost_program_options.a
LIBS += /home/user/Documents/BoostLibrary/stage/lib/libboost_program_options.so
LIBS += /home/user/Documents/BoostLibrary/stage/lib/libboost_program_options.so.1.81.0
And, how to link 2 libraries? Just to repeat LIBS+= "path" again?And just for curiosity - I am doing tutorial with that boost library, it says:
Remember that the Boost.ProgramOptions library consists of more than just header files, so
Therefore, your program must link with the libboost_program_options library.
We did linkage? -
You should only need one of those libraries. I'm working from memory, so you might want to double-check me, but an .so library is a dynamic library, while a .a is a static library. The one with a specific version number appears to be the actual library, while libboost_program_options.so is a link (so when you update boost, you don't have to rebuild your project. I'd use the link in your LIBS statement.
When you want to add multiple libraries, you can either have multiple LIBS statements (just remember to use "+=" or the second LIBS statement will undo the first), or you can concatenate the needed libs in one LIBS statement.
-
@mzimmers Thanks a lot.
But now I get other error:
I tried to google, found this:
https://stackoverflow.com/questions/36090824/trouble-using-boost-cannot-open-shared-object-file
https://forum.qt.io/topic/58963/error-while-loading-shared-libraries-cannot-open-shared-object-file-no-such-file-or-directory/3
but adding this flags from solutions doesnt work... (however, advices are very old, more than 6 years passed...) -
Interesting. We're getting away from my area of expertise -- it's been awhile since I've developed for Linux -- so I'm not sure how much help I'll be.
Looking at the link you provided...I wonder if you need to use this variable. I don't remember having to use it back when I did use Qt for Linux, but who knows.
Maybe someone more knowledgable than I can chime in here.
-
Hi,
You can define the LD_LIBRARY_PATH environment variable in the Run part of the project panel and point it to where your boost libraries are.
One question though: why not use the boost libraries from your Linux distribution ?
-
@SGaist And what I need to do here?
One question though: why not use the boost libraries from your Linux distribution ?
Because I am newbie, obviuos steps when you need a library - download it from library site.
If it will be easier to use them from Linux and link them to projects in Qt - awesome! -
See the environment block ? That's what you need to change.
-
The error you show is a run time error not a compiler error.
Where exactly is that library located ?
-
The exact debut, I don't know but at least Debian does.