Re: [Boost-users] [Serialization] Undefined reference to... (header or compilation problem)

add the "const"
Read the "rationale" section of the documentation for an explanation.
Robert Ramey
int main() {
const Vertex v1(1.5, 2.5); // add "const" here std::ofstream ofs("myfile.vtx");
boost::archive::text_oarchive oa(ofs);
oa << v1; ofs.close();
return 0; }
I'm sorry, "const" did not help. I'm almost positive it's missing libs or something similar, cause I get same errors compiling "bus stops" demo (demo.cpp) from boost tutorial. Thx for your time ! Regards Misha

Maximilian Wilson ' s post I found in archives :
Perhaps this is obvious, but it wasn't to me from Boost's documentation: you have to explicitly link in the serialization library. On gcc this would be
g++ myProgram.cpp -o myProgram -lboost_serialization-gcc
(where libboost_serialization-gcc.a is a file in your library directory $LIBRARY_PATH).
As I can see now it was a linker problem. Line: > g++ demo.cpp -o main -lboost_serialization solved it for me. Dont really get it, cause the library file name is /usr/lib/libboost_serialization.a , but I'm just happy with the result. Consider topic closed. Thanks again for your help. Regards Misha
participants (2)
-
Misha
-
mishaï¼ gildia.pl