Boost logo

Boost Users :

Subject: Re: [Boost-users] How do you compile Boost C++ code in Ubuntu?
From: Mateusz Loskot (mateusz_at_[hidden])
Date: 2013-02-08 12:45:29


On 8 February 2013 16:03, Giovanni <giovanni.ong_at_[hidden]> 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_at_vb-ubuntu104-x64:~/tmp$ /usr/bin/lsb_release -d
Description: Ubuntu 10.04.4 LTS

mloskot_at_vb-ubuntu104-x64:~/tmp$ cat bsystem.cpp
#include <boost/system/error_code.hpp>
#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_at_vb-ubuntu104-x64:~/tmp$ g++ -L/usr/lib -lboost_system bsystem.cpp
mloskot_at_vb-ubuntu104-x64:~/tmp$ ./a.out
14
application

mloskot_at_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,

--
Mateusz Loskot, http://mateusz.loskot.net

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net