Basic usage of Boost, how to compile?
I just installed the latest Boost on my Slackware64 14.1 system. It seemed to go well and as far as I know all got installed properly except the includes and lib were in a weird place. I moved the includes to /usr/local/include and linked the libs to /usr/local/lib to make it generally compatible with my setup.
But when I try to compile one of the example programs I get errors of the type indication a missing lib (i.e., undefined reference to `boost::random::random_device::random_device' and similar in this particular example). From what I read in the manual, mostly libs aren't even needed, the headers supply everything. Basically all I wanted from Boost was elliptic integrals and other special functions but I'm stuck on a simple 'how to compile' problem. |
Did you try linking against the library?
Code:
$ g++ main.cpp -lboost_random Code:
#include <iostream> |
Ok, that works, thank you. But I still haven't found in the docs what the libs are and when they are needed. I guess I always have this problem when I'm new to something. It's not that I mind feeling stupid, but I don't have time to spend on things that should be easy, I am busy already, lol.
BTW, the program compiles and runs but does it do anything useful? ^.^ Oh, one more thing: The example programs in the package compile without linking libs. Something magic seems to be going on there but IDK what it is. |
Most of the boost library is just header files, and they don't require building or linking to be used. Just include the appropriate headers and you're good to go.The boost library documentation will tell you which headers you need to include for each library.
|
You're welcome.
Quote:
|
All times are GMT -5. The time now is 07:21 AM. |