编译cpp-netlib源码时出错
Error when compiling cpp-netlib source
我已按照 documentation and I am trying to compile the http client 示例中的说明手动安装了 c++ 网络库。我正在使用 0.11
版本的库。
我正在使用这个命令进行编译:
g++ -o http_c http_client.cpp -lcppnetlib-uri -lcppnetlib-server-parsers -lcppnetlib-client-connections -lboost_thread -I/usr/local/include -L/usr/local/lib64
我得到这个错误:
In file included from /usr/include/boost/iostreams/detail/is_dereferenceable.hpp:12:0,
from /usr/include/boost/iostreams/detail/resolve.hpp:26,
from /usr/include/boost/iostreams/detail/push.hpp:24,
from /usr/include/boost/iostreams/detail/streambuf/indirect_streambuf.hpp:31,
from /usr/include/boost/iostreams/stream_buffer.hpp:22,
from /usr/include/boost/iostreams/stream.hpp:21,
from /usr/include/boost/spirit/home/qi/stream/detail/iterator_source.hpp:14,
from /usr/include/boost/spirit/home/qi/stream/stream.hpp:16,
from /usr/include/boost/spirit/home/qi/stream.hpp:15,
from /usr/include/boost/spirit/home/qi.hpp:30,
from /usr/include/boost/spirit/include/qi.hpp:16,
from /usr/local/include/boost/network/uri/accessors.hpp:12,
from /usr/local/include/boost/network/uri/uri.hpp:308,
from /usr/local/include/boost/network/protocol/http/message/wrappers/uri.hpp:10,
from /usr/local/include/boost/network/protocol/http/request.hpp:18,
from /usr/local/include/boost/network/protocol/http/client.hpp:13,
from http_client.cpp:1:
/usr/include/boost/type_traits/detail/bool_trait_def.hpp:18:79: note: #pragma message: NOTE: Use of this header (bool_trait_def.hpp) is deprecated
# pragma message("NOTE: Use of this header (bool_trait_def.hpp) is deprecated")
^
In file included from /usr/include/boost/type_traits/detail/bool_trait_def.hpp:21:0,
from /usr/include/boost/iostreams/detail/is_dereferenceable.hpp:12,
from /usr/include/boost/iostreams/detail/resolve.hpp:26,
from /usr/include/boost/iostreams/detail/push.hpp:24,
from /usr/include/boost/iostreams/detail/streambuf/indirect_streambuf.hpp:31,
from /usr/include/boost/iostreams/stream_buffer.hpp:22,
from /usr/include/boost/iostreams/stream.hpp:21,
from /usr/include/boost/spirit/home/qi/stream/detail/iterator_source.hpp:14,
from /usr/include/boost/spirit/home/qi/stream/stream.hpp:16,
from /usr/include/boost/spirit/home/qi/stream.hpp:15,
from /usr/include/boost/spirit/home/qi.hpp:30,
from /usr/include/boost/spirit/include/qi.hpp:16,
from /usr/local/include/boost/network/uri/accessors.hpp:12,
from /usr/local/include/boost/network/uri/uri.hpp:308,
from /usr/local/include/boost/network/protocol/http/message/wrappers/uri.hpp:10,
from /usr/local/include/boost/network/protocol/http/request.hpp:18,
from /usr/local/include/boost/network/protocol/http/client.hpp:13,
from http_client.cpp:1:
/usr/include/boost/type_traits/detail/template_arity_spec.hpp:13:84: note: #pragma message: NOTE: Use of this header (template_arity_spec.hpp) is deprecated
# pragma message("NOTE: Use of this header (template_arity_spec.hpp) is deprecated")
^
In file included from /usr/include/boost/iostreams/detail/is_dereferenceable.hpp:13:0,
from /usr/include/boost/iostreams/detail/resolve.hpp:26,
from /usr/include/boost/iostreams/detail/push.hpp:24,
from /usr/include/boost/iostreams/detail/streambuf/indirect_streambuf.hpp:31,
from /usr/include/boost/iostreams/stream_buffer.hpp:22,
from /usr/include/boost/iostreams/stream.hpp:21,
from /usr/include/boost/spirit/home/qi/stream/detail/iterator_source.hpp:14,
from /usr/include/boost/spirit/home/qi/stream/stream.hpp:16,
from /usr/include/boost/spirit/home/qi/stream.hpp:15,
from /usr/include/boost/spirit/home/qi.hpp:30,
from /usr/include/boost/spirit/include/qi.hpp:16,
from /usr/local/include/boost/network/uri/accessors.hpp:12,
from /usr/local/include/boost/network/uri/uri.hpp:308,
from /usr/local/include/boost/network/protocol/http/message/wrappers/uri.hpp:10,
from /usr/local/include/boost/network/protocol/http/request.hpp:18,
from /usr/local/include/boost/network/protocol/http/client.hpp:13,
from http_client.cpp:1:
/usr/include/boost/type_traits/detail/template_arity_spec.hpp:13:84: note: #pragma message: NOTE: Use of this header (template_arity_spec.hpp) is deprecated
# pragma message("NOTE: Use of this header (template_arity_spec.hpp) is deprecated")
^
/usr/bin/ld: /tmp/cczusVNF.o: undefined reference to symbol '_ZN5boost6system15system_categoryEv'
/usr/lib/libboost_system.so.1.60.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
我不知道发生了什么。
可以忽略那些关于弃用 headers 的提升警告,它们是提升 1.60.0 的已知问题。
这给您留下了对 boost 系统库的未定义引用。您是否真的在系统上安装了正在使用的 boost 库?这可能会解决您的问题。安装是OS-specific,开始here.
我已按照 documentation and I am trying to compile the http client 示例中的说明手动安装了 c++ 网络库。我正在使用 0.11
版本的库。
我正在使用这个命令进行编译:
g++ -o http_c http_client.cpp -lcppnetlib-uri -lcppnetlib-server-parsers -lcppnetlib-client-connections -lboost_thread -I/usr/local/include -L/usr/local/lib64
我得到这个错误:
In file included from /usr/include/boost/iostreams/detail/is_dereferenceable.hpp:12:0,
from /usr/include/boost/iostreams/detail/resolve.hpp:26,
from /usr/include/boost/iostreams/detail/push.hpp:24,
from /usr/include/boost/iostreams/detail/streambuf/indirect_streambuf.hpp:31,
from /usr/include/boost/iostreams/stream_buffer.hpp:22,
from /usr/include/boost/iostreams/stream.hpp:21,
from /usr/include/boost/spirit/home/qi/stream/detail/iterator_source.hpp:14,
from /usr/include/boost/spirit/home/qi/stream/stream.hpp:16,
from /usr/include/boost/spirit/home/qi/stream.hpp:15,
from /usr/include/boost/spirit/home/qi.hpp:30,
from /usr/include/boost/spirit/include/qi.hpp:16,
from /usr/local/include/boost/network/uri/accessors.hpp:12,
from /usr/local/include/boost/network/uri/uri.hpp:308,
from /usr/local/include/boost/network/protocol/http/message/wrappers/uri.hpp:10,
from /usr/local/include/boost/network/protocol/http/request.hpp:18,
from /usr/local/include/boost/network/protocol/http/client.hpp:13,
from http_client.cpp:1:
/usr/include/boost/type_traits/detail/bool_trait_def.hpp:18:79: note: #pragma message: NOTE: Use of this header (bool_trait_def.hpp) is deprecated
# pragma message("NOTE: Use of this header (bool_trait_def.hpp) is deprecated")
^
In file included from /usr/include/boost/type_traits/detail/bool_trait_def.hpp:21:0,
from /usr/include/boost/iostreams/detail/is_dereferenceable.hpp:12,
from /usr/include/boost/iostreams/detail/resolve.hpp:26,
from /usr/include/boost/iostreams/detail/push.hpp:24,
from /usr/include/boost/iostreams/detail/streambuf/indirect_streambuf.hpp:31,
from /usr/include/boost/iostreams/stream_buffer.hpp:22,
from /usr/include/boost/iostreams/stream.hpp:21,
from /usr/include/boost/spirit/home/qi/stream/detail/iterator_source.hpp:14,
from /usr/include/boost/spirit/home/qi/stream/stream.hpp:16,
from /usr/include/boost/spirit/home/qi/stream.hpp:15,
from /usr/include/boost/spirit/home/qi.hpp:30,
from /usr/include/boost/spirit/include/qi.hpp:16,
from /usr/local/include/boost/network/uri/accessors.hpp:12,
from /usr/local/include/boost/network/uri/uri.hpp:308,
from /usr/local/include/boost/network/protocol/http/message/wrappers/uri.hpp:10,
from /usr/local/include/boost/network/protocol/http/request.hpp:18,
from /usr/local/include/boost/network/protocol/http/client.hpp:13,
from http_client.cpp:1:
/usr/include/boost/type_traits/detail/template_arity_spec.hpp:13:84: note: #pragma message: NOTE: Use of this header (template_arity_spec.hpp) is deprecated
# pragma message("NOTE: Use of this header (template_arity_spec.hpp) is deprecated")
^
In file included from /usr/include/boost/iostreams/detail/is_dereferenceable.hpp:13:0,
from /usr/include/boost/iostreams/detail/resolve.hpp:26,
from /usr/include/boost/iostreams/detail/push.hpp:24,
from /usr/include/boost/iostreams/detail/streambuf/indirect_streambuf.hpp:31,
from /usr/include/boost/iostreams/stream_buffer.hpp:22,
from /usr/include/boost/iostreams/stream.hpp:21,
from /usr/include/boost/spirit/home/qi/stream/detail/iterator_source.hpp:14,
from /usr/include/boost/spirit/home/qi/stream/stream.hpp:16,
from /usr/include/boost/spirit/home/qi/stream.hpp:15,
from /usr/include/boost/spirit/home/qi.hpp:30,
from /usr/include/boost/spirit/include/qi.hpp:16,
from /usr/local/include/boost/network/uri/accessors.hpp:12,
from /usr/local/include/boost/network/uri/uri.hpp:308,
from /usr/local/include/boost/network/protocol/http/message/wrappers/uri.hpp:10,
from /usr/local/include/boost/network/protocol/http/request.hpp:18,
from /usr/local/include/boost/network/protocol/http/client.hpp:13,
from http_client.cpp:1:
/usr/include/boost/type_traits/detail/template_arity_spec.hpp:13:84: note: #pragma message: NOTE: Use of this header (template_arity_spec.hpp) is deprecated
# pragma message("NOTE: Use of this header (template_arity_spec.hpp) is deprecated")
^
/usr/bin/ld: /tmp/cczusVNF.o: undefined reference to symbol '_ZN5boost6system15system_categoryEv'
/usr/lib/libboost_system.so.1.60.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
我不知道发生了什么。
可以忽略那些关于弃用 headers 的提升警告,它们是提升 1.60.0 的已知问题。
这给您留下了对 boost 系统库的未定义引用。您是否真的在系统上安装了正在使用的 boost 库?这可能会解决您的问题。安装是OS-specific,开始here.