I installed Boost via sudo apt-get install libboost-all-dev on the most recent version of Ubuntu. Now I want to compile a project that uses the Boost.Serialization library, which needs to be linked.
I’ve tried many variants of the following, without success:
gcc -I /usr/lib code.cpp -o compiled /usr/lib/libboost_serialization.a
and
gcc -I /usr/lib code.cpp -o compiled -l libboost_serialization
The error message is:
error: ‘split_member’ is not a member of ‘boost::serialization
`
What am I missing?
You are having troubles with compiling your code, not linking. On that stage it has nothing to do with libraries. At that point the fact that you have to link against something is irrelevant.
Make sure you are including
boost/serialization/split_member.hppdirectly or indirectly and get your code compiled first.On a side note,
-Iflag is used to specify path to include files and not libraries. For libraries, use-L. But if you have installed Boost from apt, then it should already be in the path and so no additional-Ior-Lshould be required. And when you specify-l, you have to emitlibfrom the beginning of library name and not put a space between a flag and its argument. Assuming working code, something like this should do:I’d also recommend you pass
-Wallflag to make compiler be more verbose and warn you about possible mistakes in your code.