C++ Boost: undefined reference to boost::system::generic_category()

boost, c++, codeblocks, linux

Solution

You should link in the `libboost_system` library. I am not sure about codeblocks, but the g++ command-line option on your platform would be

-lboost_system

Problem

I am trying to include `Boost` libraries in my project and have been facing issues in the same. I am on Ubuntu 12.10 with Codeblocks IDE and tried installing the libraries manually reading instructions from the site, but was getting error's with header as well as to-be-built-before-use libraries. I then installed the libraries via terminalby `sudo apt-get install libboost-all-dev`. After this, in my programs on Codeblocks, I can include headers like `#include <boost/regex.hpp>` but when I try to include the header for the Filesystem library ( `#include "boost/filesystem/operations.hpp"` ), I am getting the following error: ``` /usr/include/boost/system/error_code.hpp|214|undefined reference to boost::system::generic_category()'| ``` I am not sure how to resolve this error (specifically in Codeblocks on Linux). I really could use some help here. Compiler : Gcc Program code: Only tried inlcuding the above file system `operations.hpp` file. Build log from Codeblocks: ``` Build started on: 20-11-2012 at 18:02.53 Build ended on: 20-11-2012 at 18:02.54 -------------- Build: Debug in libopenFrameworks --------------- Target is up to date. -------------- Build: Debug in reader1 --------------- make -s -f Makefile Debug linking i686 bin/reader1_debug linux obj/i686Debug/src/testApp.o: In function `__static_initialization_and_destruction_0': /usr/include/boost/system/error_code.hpp:214: undefined reference to `boost::system::generic_category()' /usr/include/boost/system/error_code.hpp:215: undefined reference to `boost::system::generic_category()' /usr/include/boost/system/error_code.hpp:216: undefined reference to `boost::system::system_category()' obj/i686Debug/src/main.o: In function `__static_initialization_and_destruction_0': /usr/include/boost/system/error_code.hpp:214: undefined reference to `boost::system::generic_category()' /usr/include/boost/system/error_code.hpp:215: undefined reference to `boost::system::generic_category()' /usr/include/boost/system/error_code.hpp:216: undefined reference to `boost::system::system_category()' collect2: ld returned 1 exit status make: *** [bin/reader1_debug] Error 1 Process terminated with status 2 (0 minutes, 1 seconds) 6 errors, 0 warnings ```

Original source

Related problems