Jump to content
  • Advertisement
Sign in to follow this  
Belgium

Linker error using boost::gregorian::to_iso_string().

This topic is 3969 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I am receiving a linker error while attempting to use boost::gregorian::to_iso_string(). The error I receive is the following; [Linker error] undefined reference to `boost::gregorian::greg_month::as_short_string() const' [Linker error] undefined reference to `boost::gregorian::greg_month::as_long_string() const' ld returned 1 exit status Anyone have any ideas on what I'm doing incorrectly here? Below is the entire source file.
#include <iostream>
#include "boost/date_time/gregorian/gregorian.hpp" 

int main()
{
    boost::gregorian::date d( boost::gregorian::day_clock::local_day() );
    std::cout << d << "\n";

    std::cout << boost::gregorian::to_iso_string(d);   // <-- Error is here.

    std::cin.get();
}


Compiler: Default compiler Executing g++.exe... g++.exe "C:\Main\Tools\Dev-Cpp\MyStuff\Tests\time.cpp" -o "C:\Main\Tools\Dev-Cpp\MyStuff\Tests\time.exe" -Wall -Wformat -Werror -s -I"C:\Main\Tools\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Main\Tools\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Main\Tools\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Main\Tools\Dev-Cpp\include\c++\3.4.2" -I"C:\Main\Tools\Dev-Cpp\include" -I"C:\Main\Tools\Dev-Cpp\Include\boost_1_34_0" -L"C:\Main\Tools\Dev-Cpp\lib" -lwininet C:\DOCUME~1\Temp/ccEHbaaa.o(.text$_ZN5boost9date_time15month_formatterINS_9gregorian10greg_monthENS0_10iso_formatIcEEcE12format_monthERKS3_RSo[boost::date_time::month_formatter<boost::gregorian::greg_month, boost::date_time::iso_format<char>, char>::format_month(boost::gregorian::greg_month const&, std::basic_ostream<char, std::char_traits<char> >&)]+0x38):time.cpp: undefined reference to `boost::gregorian::greg_month::as_short_string() const' C:\DOCUME~1\Temp/ccEHbaaa.o(.text$_ZN5boost9date_time15month_formatterINS_9gregorian10greg_monthENS0_10iso_formatIcEEcE12format_monthERKS3_RSo[boost::date_time::month_formatter<boost::gregorian::greg_month, boost::date_time::iso_format<char>, char>::format_month(boost::gregorian::greg_month const&, std::basic_ostream<char, std::char_traits<char> >&)]+0x57):time.cpp: undefined reference to `boost::gregorian::greg_month::as_long_string() const' collect2: ld returned 1 exit status Execution terminated Thanks.

Share this post


Link to post
Share on other sites
Advertisement
boost::date_time needs more than just the headers for most of its functionality. You need to build the boost library with bjam and link against the filesystem library file. There are instructions for the build steps here.

Share this post


Link to post
Share on other sites
I concur with SiCrane, only a minor correction: you need to link against the date_time library (add -lboost_date_time to the linker flags), not the filesystem library. This after you have built boost, off course.

Share this post


Link to post
Share on other sites
After spending three hours trying to build the boost libraries with bjam I've come to the conclusion that I'm an idiot. I've succeeded in nothing more than downloading a lot of files. This is especially reinforced when the Boost getting started document states "This document is designed to be an extremely gentle introduction". Pages and pages of installation documents which may as well be written in Mayan as far as my brain is concerned.

Thanks anyways.

[Edited by - Belgium on July 13, 2007 10:44:19 AM]

Share this post


Link to post
Share on other sites
For most of the boost libraries you can actually just add the source files to your project instead of doing separate compilation. For data_time they'd be in the libs/date_time/src directory. You may need to tweak some files like boost/config/user.hpp.

Share this post


Link to post
Share on other sites
Quote:
Original post by SiCrane
For most of the boost libraries you can actually just add the source files to your project instead of doing separate compilation. For data_time they'd be in the libs/date_time/src directory. You may need to tweak some files like boost/config/user.hpp.


That did the trick. Thanks!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!