我正在使用德拉科和增强。在此question之后,Draco运行良好。

我试图安装Boost,我认为它已经完成。
c++ - 未定义对 “boost::archive…” g++/wsl的引用-LMLPHP

现在我尝试在wsl的vs-code中运行以下命令:

 g++ -I ~/local/include -L ~/local/lib -o prog ObjContainer.cpp -ldracodec -lboost_system

错误:
ObjContainer.cpp:(.text._ZN5boost7archive6detail15common_iarchiveINS0_15binary_iarchiveEED2Ev[_ZN5boost7archive6detail15common_iarchiveINS0_15binary_iarchiveEED5Ev]+0x22): undefined reference to `boost::archive::detail::basic_iarchive::~basic_iarchive()'
/tmp/ccqY0aGT.o: In function `boost::archive::binary_iarchive_impl<boost::archive::binary_iarchive, char, std::char_traits<char> >::~binary_iarchive_impl()':
ObjContainer.cpp:(.text._ZN5boost7archive20binary_iarchive_implINS0_15binary_iarchiveEcSt11char_traitsIcEED2Ev[_ZN5boost7archive20binary_iarchive_implINS0_15binary_iarchiveEcSt11char_traitsIcEED5Ev]+0x32): undefined reference to `boost::archive::basic_binary_iprimitive<boost::archive::binary_iarchive, char, std::char_traits<char> >::~basic_binary_iprimitive()'
/tmp/ccqY0aGT.o: In function `boost::archive::binary_oarchive_impl<boost::archive::binary_oarchive, char, std::char_traits<char> >::binary_oarchive_impl(std::ostream&, unsigned int)':
ObjContainer.cpp:(.text._ZN5boost7archive20binary_oarchive_implINS0_15binary_oarchiveEcSt11char_traitsIcEEC2ERSoj[_ZN5boost7archive20binary_oarchive_implINS0_15binary_oarchiveEcSt11char_traitsIcEEC5ERSoj]+0x55): undefined reference to `boost::archive::basic_binary_oprimitive<boost::archive::binary_oarchive, char, std::char_traits<char> >::basic_binary_oprimitive(std::basic_streambuf<char, std::char_traits<char> >&, bool)'
ObjContainer.cpp:(.text._ZN5boost7archive20binary_oarchive_implINS0_15binary_oarchiveEcSt11char_traitsIcEEC2ERSoj[_ZN5boost7archive20binary_oarchive_implINS0_15binary_oarchiveEcSt11char_traitsIcEEC5ERSoj]+0xab): undefined reference to `boost::archive::basic_binary_oprimitive<boost::archive::binary_oarchive, char, std::char_traits<char> >::~basic_binary_oprimitive()'
/tmp/ccqY0aGT.o: In function `boost::archive::binary_iarchive_impl<boost::archive::binary_iarchive, char, std::char_traits<char> >::binary_iarchive_impl(std::istream&, unsigned int)':
ObjContainer.cpp:(.text._ZN5boost7archive20binary_iarchive_implINS0_15binary_iarchiveEcSt11char_traitsIcEEC2ERSij[_ZN5boost7archive20binary_iarchive_implINS0_15binary_iarchiveEcSt11char_traitsIcEEC5ERSij]+0x55): undefined reference to `boost::archive::basic_binary_iprimitive<boost::archive::binary_iarchive, char, std::char_traits<char> >::basic_binary_iprimitive(std::basic_streambuf<char, std::char_traits<char> >&, bool)'
ObjContainer.cpp:(.text._ZN5boost7archive20binary_iarchive_implINS0_15binary_iarchiveEcSt11char_traitsIcEEC2ERSij[_ZN5boost7archive20binary_iarchive_implINS0_15binary_iarchiveEcSt11char_traitsIcEEC5ERSij]+0xab): undefined reference to `boost::archive::basic_binary_iprimitive<boost::archive::binary_iarchive, char, std::char_traits<char> >::~basic_binary_iprimitive()'
/tmp/ccqY0aGT.o: In function `boost::archive::binary_oarchive_impl<boost::archive::binary_oarchive, char, std::char_traits<char> >::init(unsigned int)':
ObjContainer.cpp:(.text._ZN5boost7archive20binary_oarchive_implINS0_15binary_oarchiveEcSt11char_traitsIcEE4initEj[_ZN5boost7archive20binary_oarchive_implINS0_15binary_oarchiveEcSt11char_traitsIcEE4initEj]+0x21): undefined reference to `boost::archive::basic_binary_oarchive<boost::archive::binary_oarchive>::init()'

最佳答案

boost::archive类是Boost.Serialization库的一部分。

您需要在最后链接-lboost_serialization -lboost_system

08-04 02:21