6

The following code gives compile error with g++-4.7.0 but compiles fine with g++-4.6.

#include <iostream>
#include <boost/date_time/local_time/local_time.hpp>
using namespace std;
int main(){
    boost::posix_time::ptime time_t_epoch(boost::gregorian::date(1970,1,1));
    cout << time_t_epoch << endl;
    return 0;
}

The following is the error message that is repeatedly seen (compiler outputs a lot of messages)

/usr/include/boost/date_time/local_time/local_date_time.hpp:433:84: error: use of deleted function boost::shared_ptr<boost::date_time::time_zone_base<boost::posix_time::ptime, char> >::shared_ptr(const boost::shared_ptr<boost::date_time::time_zone_base<boost::posix_time::ptime, char> >&)

I am using Ubuntu 12.04 and libboost-date-time1.46.1.

Any suggestions?

chrisaycock
  • 36,470
  • 14
  • 88
  • 125
suresh
  • 1,109
  • 1
  • 8
  • 24
  • Are you using the same version of boost in both cases? – juanchopanza Apr 29 '12 at 07:11
  • Yes. I do not see any other version of boost libraries installed on my machine. Btw, it is a compile error right? so does the version of library matters here? – suresh Apr 29 '12 at 07:17
  • It is a compile error. I can't reproduce it, but my boost isn't build with c++11. It looks like yours is (constructor delete is c++11), so I am guessing boost is built differently on the latest ubuntu. Did you build it yourself, or use `get-apt install`? – juanchopanza Apr 29 '12 at 07:22
  • I installed boost using `aptitude install`. g++-4.7 from a ppa, as described [here](http://askubuntu.com/questions/113291/installing-gcc-4-7) – suresh Apr 29 '12 at 07:26
  • What commands did you use to get boost? I can't reproduce it, with gcc4.7 (albeit on ubuntu 11.10) – juanchopanza Apr 29 '12 at 07:33
  • Actually my machine was upgraded from 10.04 to 12.04. So latest boost libraries got installed during the upgrade process. – suresh Apr 29 '12 at 07:39
  • Which boost library you have on your machine? – suresh Apr 29 '12 at 07:44
  • The same as yours. Unfortunately I don't think I can help right now. I would need a virtual machine with 12.04, and I won't be setting that up in the immediate future. – juanchopanza Apr 29 '12 at 07:55
  • So you have the same gcc and boost version as of mine but no such error right? So I am wondering what could be the reason for such an error...thanks for trying to help me though :) – suresh Apr 29 '12 at 07:57

1 Answers1

6

The problem was solved by installing boost-1.48

suresh
  • 1,109
  • 1
  • 8
  • 24
  • 2
    good to hear that, now I know for when I upgrade. You are allowed to accept your own answer (but you don't get any rep points :-) ) – juanchopanza Apr 29 '12 at 09:31
  • same for me, but I was using MacOS and gcc47 (via MacPorts). Updated from boost 1.44 to 1.51. – chahuistle Sep 27 '12 at 22:13