Boost: Error help

I have just installed the Boost Library because I want to do more things with Files and Directories. I wrote a quick program that didn't use any boost functions. I did, however, include <boost/filesystem.hpp> in anticipation, because I was going to create another function which would use the boost library. Im using namespace std only in the main function so far, so I don't believe it's a namespace problem, but I might be wrong. here are the error messages that were displayed:

obj\Debug\main.o||In function `_static_initialization_and_destruction_0':|
c:\mingw\bin\..\lib\gcc\i686-pc-mingw32\4.7.1\..\..\..\..\include\boost\system\error_code.hpp|214|undefined reference to `boost::system::generic_category()'|
c:\mingw\bin\..\lib\gcc\i686-pc-mingw32\4.7.1\..\..\..\..\include\boost\system\error_code.hpp|215|undefined reference to `boost::system::generic_category()'|
c:\mingw\bin\..\lib\gcc\i686-pc-mingw32\4.7.1\..\..\..\..\include\boost\system\error_code.hpp|216|undefined reference to `boost::system::system_category()'|
||=== Build finished: 3 errors, 0 warnings ===|

I don't know why it did this, because there are absolutely no Boost functions being used. The only thing even remotely related to boost in my code was the inclusion of the boost/filesystem.hpp file.

Since I'm learning this on my own, I would appreciate any help you can give me.
Are you linking to boost_system and boost_filesystem?
Last edited on
Will you explain to me how and why I need to do that?
The functions aren't defined in the header but in library files. You need to link to those libraries so the linker can find the function definitions.
I believe in codeblocks its under project > build options > linker settings. Select add, and browse to where libboost_system.a and libboost_filesystem.a are and add each of them. You will also need to set c:/mingw/lib to search directories.
hmm I'll try that.
The include path should already be included as part of your default set up. All you should need to do is go to the Build Options and then Linker settings. Add

I believe there is a third one you need (can't remember off the top of my head however).
Do I always have to add the 'boost_system' when I use any boost libraries? (aka- not just for the filesystem)
once again, thank you Volatile Pulse! It worked with boost_system and boost_filesystem.
You'll have to check the documentation for the header, some are header only and dont require any linking while some do.
Edit: This page gives some info whether header only or linked
Last edited on
Topic archived. No new replies allowed.