0

I used boost for visual studio 2005 with version 1.48. I am receiving a linker error while attempting to use boost::gregorian::from_string().

#include <string>
#define BOOST_DATE_TIME_SOURCE
#include <boost/date_time/gregorian/gregorian.hpp>
using namespace boost::gregorian;
using namespace std;

void testDate(){
string s("2000-01-10");
date d2 = from_string(s);

}

int main()
{
testDate();
return 0;

}

and get the linker error:

error LNK2019: unresolved external symbol "public: static class boost::shared_ptr<class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,unsigned short,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,unsigned short> > > > __cdecl boost::gregorian::greg_month::get_month_map_ptr(void)" (?get_month_map_ptr@greg_month@gregorian@boost@@SA?AV?$shared_ptr@V?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@GU?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@G@std@@@2@@std@@@3@XZ) referenced in function "unsigned short __cdecl boost::date_time::month_str_to_ushort<class boost::gregorian::greg_month>(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??$month_str_to_ushort@Vgreg_month@gregorian@boost@@@date_time@boost@@YAGABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)

Why?

Mat
  • 202,337
  • 40
  • 393
  • 406

2 Answers2

0

The date time library

boost_date_time-vc140-mt.lib

was not in the lib folder. I have installed it with vcpakcgae manger and it worked.

sohel14_cse_ju
  • 2,481
  • 9
  • 34
  • 55
0

Boost.DateTime is not a header-only library for you since you are using from_string; you need to compile it from source first and then link against it in your project.

Jon
  • 428,835
  • 81
  • 738
  • 806