#11784 closed Bugs (invalid)
basic_xml_grammar.hpp
Reported by: | Owned by: | Robert Ramey | |
---|---|---|---|
Milestone: | To Be Determined | Component: | serialization |
Version: | Boost 1.59.0 | Severity: | Problem |
Keywords: | Cc: | epsilonomega2k@… |
Description
After upgrading to 1.59 I get the following linker error when I try to use xml_iarchive
../../util/libutil.a(saveload.o): In function `boost::archive::xml_iarchive_impl<boost::archive::xml_iarchive>::xml_iarchive_impl(std::istream&, unsigned int)': /(_location of local boost_)/boost/include/boost/archive/impl/xml_iarchive_impl.ipp:175: undefined reference to `boost::archive::basic_xml_grammar<char>::basic_xml_grammar()
After inspection of the source code of the library I kind of agree with the linker -- I cannot find which file contains the definition of the constructor (same applies for all other member functions of basic_xml_grammar). I do not pretend that I understand the inner workings of the serialization library, but this broke code which used to work with release 1.53.0, so something has changed.
Do you mind either pointing to me where to find the implementation of basic_xml_grammar in the source code distribution (in which case I will take care of finding out what went wrong with the linker locating the code) or if the implementation is really missing then providing it (if that were the case could you provide it before the next release -- I would like to not wait till then).
Thank you.
Change History (3)
comment:1 by , 7 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 7 years ago
This actually is a subtle problem on my platform and by extension I expect it to be a problem for some other people, so here are the details:
The compiler/linker does not make the symbols created by the instantiation of basic_xml_grammar<char> inside xml_grammar.cpp available in libboost_serialization.so.1.59.0. They are available in libboost_serialization.a, so static linking is unaffected. I observed this by running nm -g -C on both libraries.
To correct the problem for my local copy I just placed
__attribute__ ((visibility ("default")))
in the definitions of the member functions of basic_xml_grammar inside basic_xml_grammar.ipp . This forces the symbols to be placed inside the dynamic shared object library in the case of g++ (I am using g++ (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4).
I am not versed enough in compilers, pragmas and such to recommend a solution in the generic case, but I suggest that someone at least manually check that these dynamic libraries export the symbols for the members of basic_xml_grammar<char> when the compilation is made with the latest versions of g++. One does not run into this problem until one tries link versus the dynamic libraries and I am not certain that anyone ever tested this before making the release, especially if this happens only on some compilers and not others.
comment:3 by , 6 years ago
Hello,
I faced a similar issue and I noticed the same problem with libboost_serialization.so and libboost_serialization.a .
My context is that I need to make a custom xml archive with the possibility to split the archive into two different archives (one containing the main data structure, and another one listing some heavy data structures containing in the main one). For my output archive, the boost tutorial worked fine. However, for my input archive, it did not work, and I found this ticket very similar to my troubles.
I do not want to modify the boost library since I am coding in the context of a template C++ library, and I cannot use the solution proposed by epsilonomega2k. I found another workaround by adding to the headers of my library the following source files found in boost/libs/serialization/src :
basic_xml_grammar.ipp xml_grammar.cpp -> xml_grammar.ipp
It compiles on my workstation, but this does not seem to be the right way to do. Do you have any suggestion ?
Thank you.
Tom.
look in src directory. You'll find xml_iarchive.cpp which refers functions in xml_grammer.cpp. This file in turn explicitly instantiates basic_xml_grammar<char>.