Boost Date_Time problem compiling a simple program

Posted by Andry on Stack Overflow See other posts from Stack Overflow or by Andry
Published on 2011-01-17T09:42:40Z Indexed on 2011/01/17 13:53 UTC
Read the original article Hit count: 234

Filed under:
|

Hello!

I'm writing a very stupid program using Boost Date_Time library.

int main(int srgc, char** argv) {
   using namespace boost::posix_time; 
   date d(2002,Feb,1); //an arbitrary date 
   ptime t1(d, hours(5)+nanosec(100)); //date + time of day offset 
   ptime t2 = t1 - minutes(4)+seconds(2);
   ptime now = second_clock::local_time(); //use the clock 
   date today = now.date(); //Get the date part out of the time 
}

Well I cannot compile it, compiler does not recognize a type... Well I used many features of Boost libs like serialization and more... I correctly built them and, looking in my /usr/local/lib folder I can see that libboost_date_time.so is there (a good sign which means I was able to build that library)

When I compile I write the following:

g++ -lboost_date_time main.cpp

But the errors it showed me when I specify the lib are the same of those ones where I do not specify any lib.

What is this? Anyone knows?

The error is

main.cpp: In function ‘int main(int, char**)’: main.cpp:9: error: ‘date’ was not declared in this scope main.cpp:9: error: expected ‘;’ before ‘d’ main.cpp:10: error: ‘d’ was not declared in this scope main.cpp:10: error: ‘nanosec’ was not declared in this scope main.cpp:13: error: expected ‘;’ before ‘today’

© Stack Overflow or respective owner

Related posts about c++

Related posts about boost-date-time