compilation - how is linking done in c++? -
i using proxygen library facebook build simple client example . in directory have 2 object files how link them : using:
g++ -std=c++11 -o my_echo curlclientmain.o curlclient.o -lproxygenhttpserver -lfolly -lglog -lgflags -pthread
i think ma missing linker flag -lgflags in above example. maybe after including -someflag out compilation . how know possilble library flags posiible 1 have used -lproxyhttpserver.
in short these libs defined or located. using ubuntu.
here error message
in function `main': /home/kshitij/proxygen/httpclient/samples/curl/curlclientmain.cpp:91: undefined reference `proxygen::httpconnector::httpconnector(proxygen::httpconnector::callback*, folly::hhwheeltimer*)' /home/kshitij/proxygen/httpclient/samples/curl/curlclientmain.cpp:102: undefined reference `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 `proxygen::httpconnector::~httpconnector()' /home/kshitij/proxygen/httpclient/samples/curl/curlclientmain.cpp:99: undefined reference `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 `proxygen::httpconnector::~httpconnector()' curlclient.o: in function `curlservice::curlclient::connectsuccess(proxygen::httpupstreamsession*)': /home/kshitij/proxygen/httpclient/samples/curl/curlclient.cpp:69: undefined reference `proxygen::httpupstreamsession::newtransaction(proxygen::httptransactionhandler*)' collect2: error: ld returned 1 exit status kshitij@forgetit:~/proxygen/httpclient/samples/curl$ g++ -std=c++11 -o my_echo curlclientmain.o curlclient.o -lproxygenhttpserver -lfolly -lglog -lgflags -pthread curlclientmain.o: in function `main': /home/kshitij/proxygen/httpclient/samples/curl/curlclientmain.cpp:91: undefined reference `proxygen::httpconnector::httpconnector(proxygen::httpconnector::callback*, folly::hhwheeltimer*)' /home/kshitij/proxygen/httpclient/samples/curl/curlclientmain.cpp:102: undefined reference `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 `proxygen::httpconnector::~httpconnector()' /home/kshitij/proxygen/httpclient/samples/curl/curlclientmain.cpp:99: undefined reference `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 `proxygen::httpconnector::~httpconnector()' curlclient.o: in function `curlservice::curlclient::connectsuccess(proxygen::httpupstreamsession*)': /home/kshitij/proxygen/httpclient/samples/curl/curlclient.cpp:69: undefined reference `proxygen::httpupstreamsession::newtransaction(proxygen::httptransactionhandler*)' collect2: error: ld returned 1 exit status
how know possilble library flags posiible 1 have used -lproxyhttpserver.
it depends on compilation environment.
you appear use gnu compiler in linux. there tool list installed shared libraries:
ldconfig -p
you list of lines this
libpthread.so.0 (libc6,x86-64, os abi: linux 2.6.32) => /lib/x86_64-linux-gnu/libpthread.so.0
remove lib
prefix , extension .so.x
, name of library. in case it's pthread
. link libray use option -lname
. so, -lpthread
in example.
in short these libs defined or located
the righthand part of =>
full path library.
Comments
Post a Comment