代理中的 HTTP 客户端


嗨,我

正在使用Facebook的Proxygen来创建一个简单的hhtpclient。 我正在尝试运行他们默认的HTTPclient示例。我正在使用以下命令来构建它:

 g++ -std=c++11 -o my_echo   CurlClient.o CurlClientMain.o -lproxygenhttpserver -lfolly -lglog -lgflags -pthread

但是我收到以下错误:

CurlClient.o: In function `CurlService::CurlClient::connectSuccess(proxygen::HTTPUpstreamSession*)':
/home/kshitij/proxygen/httpclient/samples/curl/CurlClient.cpp:69: undefined reference to `proxygen::HTTPUpstreamSession::newTransaction(proxygen::HTTPTransactionHandler*)'
CurlClientMain.o: In function `main':
/home/kshitij/proxygen/httpclient/samples/curl/CurlClientMain.cpp:91: undefined reference to `proxygen::HTTPConnector::HTTPConnector(proxygen::HTTPConnector::Callback*, folly::HHWheelTimer*)'
/home/kshitij/proxygen/httpclient/samples/curl/CurlClientMain.cpp:102: undefined reference to `proxygen::HTTPConnector::connect(folly::EventBase*, folly::SocketAddress const&, std::chrono::duration<long, std::ratio<1l, 1000l> >, std::map<folly::AsyncSocket::OptionKey, int, std::less<folly::AsyncSocket::OptionKey>, std::allocator<std::pair<folly::AsyncSocket::OptionKey const, int> > > const&, folly::SocketAddress const&)'
/home/kshitij/proxygen/httpclient/samples/curl/CurlClientMain.cpp:91: undefined reference to `proxygen::HTTPConnector::~HTTPConnector()'
/home/kshitij/proxygen/httpclient/samples/curl/CurlClientMain.cpp:99: undefined reference to `proxygen::HTTPConnector::connectSSL(folly::EventBase*, folly::SocketAddress const&, std::shared_ptr<folly::SSLContext> const&, ssl_session_st*, std::chrono::duration<long, std::ratio<1l, 1000l> >, std::map<folly::AsyncSocket::OptionKey, int, std::less<folly::AsyncSocket::OptionKey>, std::allocator<std::pair<folly::AsyncSocket::OptionKey const, int> > > const&, folly::SocketAddress const&, std::string const&)'
/home/kshitij/proxygen/httpclient/samples/curl/CurlClientMain.cpp:91: undefined reference to `proxygen::HTTPConnector::~HTTPConnector()'
collect2: error: ld returned 1 exit status

可能的错误是什么。如果我以错误的方式构建它,请纠正我。

g++ -std=c++11 -o my_echo CurlClient.o CurlClientMain.o HttpUpstreamSession.o -lproxygenhttpserver -lfolly -lglog -lgflags -pthread

引用了 HttpUpstreamSession.h 包含,但实现是在同一目录中的.cpp中定义的。您需要生成.cpp或在生成中使用 .o 文件。

我用来编译该示例的内容:

gcc -I/usr/local/include -o a.out CurlClientMain.cpp CurlClient.cpp -L/usr/local/lib -lglog -lgflags -lstdc++ -lfolly -lproxygenlib -lpthread -lcrypto -lssl -lz -lwangle

请注意包含libproxygenlib

相关内容

  • 没有找到相关文章

最新更新