Hi, does anyone know why I am getting these error messages?
I'm using Code::Blocks IDE and MinGW(GCC) compiler.
I included boost (v1.39.0) libraries already. I can use them correctly with #include <boost/lexical_cast.hpp>
Also, I defined BOOST_NO_DEPRECATED

#include <boost/filesystem/operations.hpp>
#include <string>
using namespace std;

int main()
{
    //The meta data file that holds the names of all objects that can be backed up
    const string OBJECT_META = "Files.lst";
    cout << boost::filesystem::file_size(OBJECT_META);
    return 0;
}
obj\Release\main.o:main.cpp:(.text+0x1b)||undefined reference to `boost::system::get_system_category()'|
obj\Release\main.o:main.cpp:(.text+0x25)||undefined reference to `boost::system::get_generic_category()'|
obj\Release\main.o:main.cpp:(.text+0x2f)||undefined reference to `boost::system::get_generic_category()'|
obj\Release\main.o:main.cpp:(.text+0x39)||undefined reference to `boost::system::get_generic_category()'|
obj\Release\main.o:main.cpp:(.text+0x43)||undefined reference to `boost::system::get_system_category()'|
)]+0xcc)||undefined reference to `boost::filesystem::detail::file_size_api(std::string const&)'|
||=== Build finished: 6 errors, 0 warnings ===|

Thanks.

could be that you didn't add the boost libraries to your program's project. Did you compile them after installing boost?

Yeah, I have Boost installed. I painstakingly manually compiled them as well using some bjam or something like that (it might be a problem with that).
I updated the first post:

I'm using Code::Blocks IDE and MinGW(GCC) compiler.
I included boost (v1.39.0) libraries already. I can use them correctly with #include <boost/lexical_cast.hpp>
Also, I defined BOOST_NO_DEPRECATED

I tested it in MS VC++ and it works (I forgot to add #include<iostream> in the first post, but it works fine in MS VC++ if I add that one line).
Also, #include <boost/date_time.hpp> works fine in my setup with Code Blocks and GCC.

EDIT: Okay I am looking at the Boost Guide now.
Apparently, I can't just use

bootstrap
.\bjam

So, I will try to build it again for GCC and see if it works then.

Sorry for double posting and all that. I'll probably come back to post a third one with my results in like 3-4 hours.

Sorry for the delay, the building took really long...

I did the boost building thing with

bjam --build-dir=C:\Cpp\target toolset=gcc --build-type=complete stage

It still gives me the same errors, even when I moved the resulting folders into a place where the linker could find them.
I don't know.

I don't understand this link, but it seems related: http://www.boost.org/doc/libs/1_39_0/libs/filesystem/doc/index.htm#Cgywin
I tried adding

#define BOOST_POSIX_AP

but I still get the errors.


EDIT: I seem to be getting this error with all Boost libraries that require pre-built libraries. If this is a Code Blocks issue, sorry for the confusion.

commented: This post and the previous ones got me pointed in the right direction. +0

I had the same problem using the same environment. I was trying to use the boost date/time library in a program I was developing on my Windows Vista machine running Code::Blocks using the MinGW gcc compiler. Like the previous poster, after reading the boost getting started guide I realized that I needed to build the boost libraries with gcc. I tried

bootstrap
bjam --build-dir=C:\boost --build-type=complete gcc stage

, but it failed, complaining that 1 target was found and 1 was not. Then I put the path to my MinGW compiler in my PATH environment variable. To do this on Vista, I right-clicked on "Computer" in the Start Menu, selected "properties", selected "Advanced system settings", pressed the "Environment variables" button, found path in the list box, pressed "Edit", and appended ";C"\MinGW\bin" (where my gcc.exe lives) to the string. Then I tried the bjam command above again, and this time it worked. Once I linked to the new libraries bjam created, my program linked fine.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.