0

When I am including the asio header:

#include <boost/asio.hpp>

I got the error:

undefined reference to boost::system::generic_category()

So I read that I had to link to boost_system which I did. But now it gives the error::

cannot find -lboost_system

Why can it not find boost_system. I'm using Codeblocks on Windows.

template boy
  • 10,230
  • 8
  • 61
  • 97
  • Where does it look for boost_system? – zmbq Jan 06 '15 at 20:19
  • @zmbq I set the library path to "C:\Program Files\boost_1_55_0\libs" – template boy Jan 06 '15 at 20:26
  • possible duplicate of [C++ Boost: undefined reference to boost::system::generic\_category()](http://stackoverflow.com/questions/13467072/c-boost-undefined-reference-to-boostsystemgeneric-category) – l'L'l Jan 06 '15 at 20:27
  • @l'L'l The answer there says to link to `-lboost_system`. But that's what's giving me this error in the first place. – template boy Jan 06 '15 at 20:41

1 Answers1

0

boost is a separate library that needs to be installed on you building machine. Please follow these instructions to install: http://www.boost.org/doc/libs/1_55_0/doc/html/bbv2/installation.html http://www.boost.org/ After installation your application needs to be able to find it if it is not installed in a standard location.

you will need to supply the header and lib directories to the build process.

g++ source source.cpp -I/path to boost headers -L path to boost libs -lboost_system

Look inside you libs directory to be sure that you have boost_system. It is possible depending on the build that you may only have boost_system-mt

slackwars
  • 504
  • 5
  • 18
  • Weird. When I look inside "C:\Program Files\boost_1_55_0\libs" I can't find anything called `boost_system`. It's just a bunch of other folders. – template boy Jan 06 '15 at 20:53
  • I have updated my answer. It appears that you only downloaded and did not bootstrap and install. – slackwars Jan 06 '15 at 22:24
  • What should `PREFIX` be when installing Boost.Build? Can it be anything I want or does it need to be somewhere specific? – template boy Jan 08 '15 at 21:17
  • It can really be anywhere. But try to keep it in a location accessible for development. – slackwars Jan 08 '15 at 21:20
  • Will I have to make a folder to put it in or will it create a folder itself (it won't flood the directory with files)? – template boy Jan 08 '15 at 21:23
  • I installed boost build and I have a `bin` and `share` directory in the `PREFIX` directory that I specified. What do I do now?? – template boy Jan 13 '15 at 23:17