I've been trying to go through Boost tutorials but I got stuck at linking the filesystem library.
I have Ubuntu 12.10. Installation wasn't that hard
sudo apt-get install libboost-all-dev
This put all headers in /usr/local/include and compiled sources in /usr/lib/
[--headers]
[--binaries]
I wrote this program [--program]. When I tried to compiled it
g++ -g tut1.cpp -o tut1 -lboost_system -lboost_filesystem
got this errors: [--errors].
After a little search on http://www.boost.org/doc/libs/1_53_0/more/getting_started/unix-variants.html
I tried this:
g++ -g -I /usr/local/include/boost/ tut1.cpp -o tut1 -L /usr/lib/libboost_filesystem.a -lboost_system -lboost_filesystem
but didn't have luck. I had the same errors.
Since I cannot put more than 2 links in the post, here are all links
http://pastebin.com/DakVFn12
Include Boost headers and link with Boost librarieshpp> in your source file. In your project's build options, highlight the root of your project, select the "Linker settings" tab, and add "boost_*-mgwXX-mt-1_47" to your Link libraries.
In the properties dialog, select "Configuration Properties" and then "VC++ Directories". You will need to add the Boost include path to the "Include Directories" list. If you're using all header-only libraries then you're done. Otherwise, you will need to add the Boost library path to "Library Directories".
Download the latest version (1.43. 0) of the Boost libraries from the Boost website and follow the steps in the getting started guide, which explains how to build Boost on a number of platforms, including Linux.
I found the answer myself here:
http://www.richelbilderbeek.nl/CppLinkErrorUndefinedReferenceToBoostFilesystemDetailGet_current_path_api.htm
Looks like binaries weren't in /usr/lib but in /usr/local/lib.
So the correct command for compilation would be:
g++ -g tut1.cpp -o tut1 -L/usr/local/lib/ -lboost_filesystem
@Yuushi, that was 1 problem.
The -L
command should be the base path where the libraries are contained, not the path to a specific library. Try with -L /usr/lib/
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With