Re: [Boost-users] How do you compile Boost C++ code in Ubuntu?

Greetings All,
Thank you so much, Mr. Maddock.
I was able to compile my program successfully and resolve my linking
errors with your help.
Also, thank you very much, Mr. Loskot! I appreciate all the precious
time that you have spent to help me out.
Have an awesome weekend!
Regards
On Fri, Feb 8, 2013 at 8:20 AM, John Maddock
It is a quirk of GCC that the libraries used by a source file must appear *after* the source file. Nothing to do with Boost really...
John.
On Fri, Feb 8, 2013 at 9:45 AM, Mateusz Loskot
On 8 February 2013 16:03, Giovanni
wrote: I followed your instructions to link the libraries, with the "-lboost_filesystem -lboost_system" sequence of linking the aforementioned Boost C++ libraries.
However, I cannot resolve the linking error. I have included a snippet from my Terminal session below.
No idea what's wrong really and have no time to investigate it. But, I've done quick test on Ubuntu 10.04 using Boost 1.40 installed from its packages and small sample from this book http://en.highscore.de/cpp/boost/errorhandling.html and it worked for me:
Here is my console log:
mloskot@vb-ubuntu104-x64:~/tmp$ /usr/bin/lsb_release -d Description: Ubuntu 10.04.4 LTS
mloskot@vb-ubuntu104-x64:~/tmp$ cat bsystem.cpp #include
#include <iostream> #include <string> class application_category : public boost::system::error_category { public: const char *name() const { return "application"; } std::string message(int ev) const { return "error message"; } };
application_category cat;
int main() { boost::system::error_code ec(14, cat); std::cout << ec.value() << std::endl; std::cout << ec.category().name() << std::endl; }
mloskot@vb-ubuntu104-x64:~/tmp$ g++ -L/usr/lib -lboost_system bsystem.cpp mloskot@vb-ubuntu104-x64:~/tmp$ ./a.out 14 application
mloskot@vb-ubuntu104-x64:~/tmp$ ldd ./a.out |grep boost libboost_system.so.1.40.0 => /usr/lib/libboost_system.so.1.40.0 (0x00007f2df87b6000)
Perhaps something has changed in later versions. I have no time to dig it deeper, sorry.
Best regards,
participants (1)
-
Giovanni