Compilation problems with greg_serialize.hpp

Open
#181 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp
Domain
tooling

Research direction

Start with boost/date_time/gregorian/greg_serialize.hpp and the minimal program in the issue, then compare its dependencies with boost/archive/text_oarchive.hpp and boost/date_time/gregorian/gregorian.hpp. Verify that the intended include arrangement compiles and links without unexplained ordering requirements; done means the reported errors are resolved and the example builds successfully.

Written by the indexing model from the issue text.

Description

I noticed that the following code doesn't compile:

#include <sstream>
#include <iostream>

#include <boost/date_time/gregorian/greg_serialize.hpp>
#include <boost/archive/text_oarchive.hpp>

int main()
{
    boost::gregorian::date d(2021, boost::date_time::Feb, 14);

    std::ostringstream oss;
    boost::archive::text_oarchive oa(oss);
    oa & d;

    std::cout << oss.str() << std::endl;
    return 0;
}

it throws the following error:

boost/date_time/gregorian/greg_serialize.hpp:34:15: error: ‘split_free’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]

And if we invert the order of the two boost inclusion headers (putting first text_oarchive.hpp and then greg_serialize.hpp) then it compiles but doesn't link:

main.cpp:(.text._ZN5boost13serialization4saveINS_7archive13text_oarchiveEEEvRT_RKNS_9gregorian4dateEj[_ZN5boost13serialization4saveINS_7archive13text_oarchiveEEEvRT_RKNS_9gregorian4dateEj]+0x36): undefined reference to `boost::gregorian::to_iso_string[abi:cxx11](boost::gregorian::date const&)'

In order to get it linked I added a new header: #include <boost/date_time/gregorian/gregorian.hpp>

So it seems that the header boost/date_time/gregorian/greg_serialize.hpp has missing dependencies, right? I didn't see any special consideration in the documentation of the library about using this header in a specific order.

Dominant language
C++
Stars
70
Forks
99
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/date_time

All issues in boostorg/date_time

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.