daldegam / eos-portable-archive

10 stars 8 forks source link

Error loading file in boost 1.69.0 #4

Closed JLDDER closed 2 years ago

JLDDER commented 3 years ago

I can't find portablebinary(i)oarchive in boost/archive. so, I tried to copy those files in eos to boost/archive. Then, it is different from tutorial, I can't use boost::archive::portable_binary_oarchive but eos::portable_oarchive could.

    template<class Archive>
    void Map::serialize(Archive &ar, const unsigned int version)
    {
        // don't save mutex
        ar & mspMapPoints;
        ar & mvpKeyFrameOrigins;
        ar & mspKeyFrames;
        ar & mvpReferenceMapPoints;
        ar & mnMaxKFid & mnBigChangeIdx;
        ar & mapScaleRatio;
    }
    template void Map::serialize(eos::portable_oarchive&, const unsigned int);
    template void Map::serialize(eos::portable_iarchive&, const unsigned int);

Next, when I compile code, it will show the warning: The use of BOOST__ENDIAN and BOOST_BYTE_ORDER is deprecated. Please include <boost/predef/other/endian.h> and use BOOSTENDIAN_BYTE instead Finally, It saved the file but I can't load it.

Help me find where wrong, thanks.

romariorios commented 3 years ago

I managed to create a minimal project that manages to reproduce this issue: test-eos.

The problem happens during the save, not the load, of the archive.

To reproduce the issue, I serialize a string. When trying to deserialize the string from the binary archive, nothing is loaded, as you described.

A few remarks:

Some of my colleagues also dug into this problem and it seems that there's something corrupting the version header of the archive while the portable archive tries to save it (the version comes back as 0).

I hope this helps.