hi i am using proxygen by facebook to create a simple hhtpclient . i am trying to run their default httpclient example. I am using the following command to build it:
g++ -std=c++11 -o my_echo CurlClient.o CurlClientMain.o -lproxygenhttpserver -lfolly -lglog -lgflags -pthread
but i am getting the following error:
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
what could be the possible error. correct me if i am building it the wrong way.
g++ -std=c++11 -o my_echo CurlClient.o CurlClientMain.o HttpUpstreamSession.o -lproxygenhttpserver -lfolly -lglog -lgflags -pthread
The HttpUpstreamSession.h include is referenced but the implementation is defined in its .cpp in the same directory. You need to either build the .cpp or use the .o file in your build.
What I used to compile that example:
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
Note the inclusion of libproxygenlib.
Related
After looking ant trying all links on the web i just can't figure what is wrong.
g++ version :
g++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
This is my compilation line :
/usr/bin/g++ -fdiagnostics-color=always -Wall -std=c++11 -DSTATIC_CONCPP -I/home/vagrant/cpp/mysql-connector-cpp/include/ -I/home/vagrant/cpp/mysql-connector-cpp/include/mysqlx/ -I/home/vagrant/cpp/mysql-connector-cpp/common/ -I/home/vagrant/cpp/boost/ -I/home/vagrant/cpp/mysql-connector-cpp/build/cdk/protocol/mysqlx/protobuf -g /home/vagrant/cpp/mysql_conn_app/main.cpp /home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a -lssl -lcrypto -lpthread -lresolv -o /home/vagrant/cpp/mysql_conn_app/main.exe
This is the error:
/tmp/ccUnnhKN.o: In function `mysqlx::abi2::r0::string::traits<char>::from_str(mysqlx::abi2::r0::string&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/vagrant/cpp/mysql-connector-cpp/include/mysqlx/devapi/common.h:220: undefined reference to `mysqlx::abi2::r0::string::Impl::from_utf8(mysqlx::abi2::r0::string&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/tmp/ccUnnhKN.o: In function `mysqlx::abi2::r0::string::traits<char>::to_str[abi:cxx11](mysqlx::abi2::r0::string const&)':
/home/vagrant/cpp/mysql-connector-cpp/include/mysqlx/devapi/common.h:225: undefined reference to `mysqlx::abi2::r0::string::Impl::to_utf8[abi:cxx11](mysqlx::abi2::r0::string const&)'
/tmp/ccUnnhKN.o: In function `mysqlx::abi2::r0::SessionSettings::SessionSettings(mysqlx::abi2::r0::string const&)':
/home/vagrant/cpp/mysql-connector-cpp/include/mysqlx/devapi/settings.h:526: undefined reference to `mysqlx::abi2::r0::common::Settings_impl::set_from_uri(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a(libcdk_proto_mysqlx_protocol.cc.o): In function `cdk::protocol::mysqlx::log_handler_init()':
./build/cdk/protocol/mysqlx/./cdk/protocol/mysqlx/protocol.cc:131: undefined reference to `google::protobuf::SetLogHandler(void (*)(google::protobuf::LogLevel, char const*, int, std::string const&))'
/home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a(libcdk_proto_mysqlx_protocol.cc.o): In function `cdk::protocol::mysqlx::Protocol_server::snd_Ok(cdk::foundation::string const&)':
./build/cdk/protocol/mysqlx/./build/cdk/protocol/mysqlx/protobuf/mysqlx.pb.h:947: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::string&&, google::protobuf::Arena*)'
/home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a(libcdk_proto_mysqlx_protocol.cc.o): In function `cdk::protocol::mysqlx::Protocol_server::snd_Error(unsigned short, cdk::foundation::string
....
what is wrong here ?
also when adding "-D_GLIBCXX_USE_CXX11_ABI=0" as suggested here:
still not working
/usr/bin/g++ -fdiagnostics-color=always -Wall -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -DSTATIC_CONCPP -I/home/vagrant/cpp/mysql-connector-cpp/include/ -I/home/vagrant/cpp/mysql-connector-cpp/include/mysqlx/ -I/home/vagrant/cpp/mysql-connector-cpp/common/ -I/home/vagrant/cpp/boost/ -I/home/vagrant/cpp/mysql-connector-cpp/build/cdk/protocol/mysqlx/protobuf -g /home/vagrant/cpp/mysql_conn_app/main.cpp /home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a -lssl -lcrypto -lpthread -lresolv -o /home/vagrant/cpp/mysql_conn_app/main.exe
gives :
/home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a(libcdk_proto_mysqlx_protocol.cc.o): In function `cdk::protocol::mysqlx::log_handler_init()':
./build/cdk/protocol/mysqlx/./cdk/protocol/mysqlx/protocol.cc:131: undefined reference to `google::protobuf::SetLogHandler(void (*)(google::protobuf::LogLevel, char const*, int, std::string const&))'
/home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a(libcdk_proto_mysqlx_protocol.cc.o): In function `cdk::protocol::mysqlx::Protocol_server::snd_Ok(cdk::foundation::string const&)':
./build/cdk/protocol/mysqlx/./build/cdk/protocol/mysqlx/protobuf/mysqlx.pb.h:947: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::string&&, google::protobuf::Arena*)'
/home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a(libcdk_proto_mysqlx_protocol.cc.o): In function `cdk::protocol::mysqlx::Protocol_server::snd_Error(unsigned short, cdk::foundation::string const&)':
./build/cdk/protocol/mysqlx/./build/cdk/protocol/mysqlx/protobuf/mysqlx.pb.h:1146: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::string&&, google::protobuf::Arena*)'
/home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a(libcdk_proto_mysqlx_protocol.cc.o): In function `cdk::protocol::mysqlx::Expr_builder_base::set_call(cdk::protocol::mysqlx::api::Db_obj const&)':
./build/cdk/protocol/mysqlx/./build/cdk/protocol/mysqlx/protobuf/mysqlx_expr.pb.h:2562: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::string&&, google::protobuf::Arena*)'
adding protobuf + -D_GLIBCXX_USE_CXX11_ABI=0 same error:
/usr/bin/g++ -fdiagnostics-color=always -Wall -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -DSTATIC_CONCPP -I/home/vagrant/cpp/mysql-connector-cpp/include/ -I/home/vagrant/cpp/mysql-connector-cpp/include/mysqlx/ -I/home/vagrant/cpp/mysql-connector-cpp/common/ -I/home/vagrant/cpp/boost/ -I/home/vagrant/cpp/mysql-connector-cpp/build/cdk/protocol/mysqlx/protobuf -g /home/vagrant/cpp/mysql_conn_app/main.cpp /home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a /home/vagrant/cpp/mysql-connector-cpp/build/cdk/protocol/mysqlx/protobuf/protobuf-3.19.4/cmake/libprotobufd.a /home/vagrant/cpp/mysql-connector-cpp/build/cdk/protocol/mysqlx/protobuf/protobuf-3.19.4/cmake/libprotobuf-lited.a /home/vagrant/cpp/mysql-connector-cpp/build/cdk/protocol/mysqlx/protobuf/protobuf-3.19.4/cmake/libprotocd.a -lssl -lcrypto -lpthread -lresolv -o /home/vagrant/cpp/mysql_conn_app/main.exe
gives :
/home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a(libcdk_proto_mysqlx_protocol.cc.o): In function `cdk::protocol::mysqlx::log_handler_init()':
./build/cdk/protocol/mysqlx/./cdk/protocol/mysqlx/protocol.cc:131: undefined reference to `google::protobuf::SetLogHandler(void (*)(google::protobuf::LogLevel, char const*, int, std::string const&))'
/home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a(libcdk_proto_mysqlx_protocol.cc.o): In function `cdk::protocol::mysqlx::Protocol_server::snd_Ok(cdk::foundation::string const&)':
./build/cdk/protocol/mysqlx/./build/cdk/protocol/mysqlx/protobuf/mysqlx.pb.h:947: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::string&&, google::protobuf::Arena*)'
/home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a(libcdk_proto_mysqlx_protocol.cc.o): In function `cdk::protocol::mysqlx::Protocol_server::snd_Error(unsigned short, cdk::foundation::string const&)':
./build/cdk/protocol/mysqlx/./build/cdk/protocol/mysqlx/protobuf/mysqlx.pb.h:1146: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::string&&, google::protobuf::Arena*)'
/home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a(libcdk_proto_mysqlx_protocol.cc.o): In function `cdk::protocol::mysqlx::Expr_builder_base::set_call(cdk::protocol::mysqlx::api::Db_obj const&)':
./build/cdk/protocol/mysqlx/./build/cdk/protocol/mysqlx/protobuf/mysqlx_expr.pb.h:2562: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::string&&, google::protobuf::Arena*)'
./build/cdk/protocol/mysqlx/./build/cdk/protocol/mysqlx/protobuf/mysqlx_expr.pb.h:2631: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::string&&, google::protobuf::Arena*)'
/home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a(libcdk_proto_mysqlx_protocol.cc.o): In function `cdk::protocol::mysqlx::Expr_builder_base::var(cdk::foundation::string const&)':
./build/cdk/protocol/mysqlx/./build/cdk/protocol/mysqlx/protobuf/mysqlx_expr.pb.h:2013: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::string&&, google::protobuf::Arena*)'
/home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a(libcdk_proto_mysqlx_protocol.cc.o):./build/cdk/protocol/mysqlx/./build/cdk/protocol/mysqlx/protobuf/mysqlx_expr.pb.h:2874: more undefined references to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::string&&, google::protobuf::Arena*)' follow
/home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a(libcdk_proto_mysqlx_protocol.cc.o): In function `void google::protobuf::internal::ArenaStringPtr::Set<google::protobuf::internal::ArenaStringPtr::EmptyDefault>(google::protobuf::internal::ArenaStringPtr::EmptyDefault, char const*, google::protobuf::Arena*)':
./build/cdk/protocol/mysqlx/./cdk/extra/protobuf/protobuf-3.19.4/src/google/protobuf/arenastring.h:200: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::string const&, google::protobuf::Arena*)'
I learn c++ following The Stroustroup's book (Programming: Principles and Practice), so I've been trying to run an example using FLTK libraries (I use Ubuntu 14.04).
Actually, when I compiled the programm with Code::Blocks IDE everything worked fine. But then, sort of for learning purposes, I decided to write a makefile, which causes many errors when trying to start it:
> g++ main.o Graph.o GUI.o Simple_window.o Window.o -o hello main.o: In function `fl_color()':
> main.cpp:(.text._Z8fl_colorv[_Z8fl_colorv]+0x7): undefined reference
> to `fl_graphics_driver' main.o: In function
> `Graph_lib::Window::~Window()':
> main.cpp: (.text._ZN9Graph_lib6WindowD2Ev[_ZN9Graph_lib6WindowD5Ev]+0x31):
> undefined reference to `Fl_Window::~Fl_Window()'
> main.o:(.rodata._ZTV13Simple_window[_ZTV13Simple_window]+0x28):
> undefined reference to `Fl_Window::handle(int)'
> main.o:(.rodata._ZTV13Simple_window[_ZTV13Simple_window]+0x30):
> undefined reference to `Fl_Window::resize(int, int, int, int)'
> main.o:(.rodata._ZTV13Simple_window[_ZTV13Simple_window]+0x38):
> undefined reference to `Fl_Window::show()'
> main.o:(.rodata._ZTV13Simple_window[_ZTV13Simple_window]+0x40):
> undefined reference to `Fl_Window::hide()'
> main.o:(.rodata._ZTV13Simple_window[_ZTV13Simple_window]+0x60):
> undefined reference to `Fl_Window::flush()' Graph.o: In function
> `Graph_lib::Text::draw_lines() const': Graph.cpp:(.text+0x9e5):
> undefined reference to `fl_draw(char const*, int, int)' Graph.o: In
> function `Graph_lib::draw_mark(Graph_lib::Point, char)':
> Graph.cpp:(.text+0x16e2): undefined reference to `fl_draw(char const*,
> int, int)' Graph.o: In function
> `Graph_lib::Image::Image(Graph_lib::Point, std::string,
> Graph_lib::Suffix::Encoding)': Graph.cpp:(.text+0x1f95): undefined
> reference to `Fl_JPEG_Image::Fl_JPEG_Image(char const*)'
> Graph.cpp:(.text+0x1fc9): undefined reference to
> `Fl_GIF_Image::Fl_GIF_Image(char const*)' Graph.cpp:(.text+0x1ffd):
> undefined reference to `Fl_BMP_Image::Fl_BMP_Image(char const*)'
> Graph.o: In function `Fl_Image::Fl_Image(int, int, int)':
> Graph.cpp:(.text._ZN8Fl_ImageC2Eiii[_ZN8Fl_ImageC5Eiii]+0x18):
> undefined reference to `vtable for Fl_Image' Graph.o: In function
> `fl_color(unsigned int)':
> Graph.cpp:(.text._Z8fl_colorj[_Z8fl_colorj]+0xe): undefined reference
> to `fl_graphics_driver'
> Graph.cpp:(.text._Z8fl_colorj[_Z8fl_colorj]+0x21): undefined reference
> to `fl_graphics_driver' Graph.o: In function `fl_line_style(int, int,
> char*)':
> Graph.cpp:(.text._Z13fl_line_styleiiPc[_Z13fl_line_styleiiPc]+0x15):
> undefined reference to `fl_graphics_driver'
> Graph.cpp:(.text._Z13fl_line_styleiiPc[_Z13fl_line_styleiiPc]+0x26):
> undefined reference to `fl_graphics_driver' Graph.o: In function
> `fl_rect(int, int, int, int)':
> Graph.cpp:(.text._Z7fl_rectiiii[_Z7fl_rectiiii]+0x17): undefined
> reference to `fl_graphics_driver'
> Graph.o:Graph.cpp:(.text._Z7fl_rectiiii[_Z7fl_rectiiii]+0x28): more
> undefined references to `fl_graphics_driver' follow Graph.o: In
> function `Graph_lib::Bad_image::draw(int, int, int, int, int, int)':
> Graph.cpp:(.text._ZN9Graph_lib9Bad_image4drawEiiiiii[_ZN9Graph_lib9Bad_image4drawEiiiiii]+0x2d): undefined reference to `Fl_Image::draw_empty(int, int)'
> Graph.o:(.rodata._ZTVN9Graph_lib9Bad_imageE[_ZTVN9Graph_lib9Bad_imageE]+0x20):
> undefined reference to `Fl_Image::copy(int, int)'
> Graph.o:(.rodata._ZTVN9Graph_lib9Bad_imageE[_ZTVN9Graph_lib9Bad_imageE]+0x28):
> undefined reference to `Fl_Image::color_average(unsigned int, float)'
> Graph.o:(.rodata._ZTVN9Graph_lib9Bad_imageE[_ZTVN9Graph_lib9Bad_imageE]+0x30):
> undefined reference to `Fl_Image::desaturate()'
> Graph.o:(.rodata._ZTVN9Graph_lib9Bad_imageE[_ZTVN9Graph_lib9Bad_imageE]+0x38):
> undefined reference to `Fl_Image::label(Fl_Widget*)'
> Graph.o:(.rodata._ZTVN9Graph_lib9Bad_imageE[_ZTVN9Graph_lib9Bad_imageE]+0x40):
> undefined reference to `Fl_Image::label(Fl_Menu_Item*)'
> Graph.o:(.rodata._ZTVN9Graph_lib9Bad_imageE[_ZTVN9Graph_lib9Bad_imageE]+0x50):
> undefined reference to `Fl_Image::uncache()' Graph.o: In function
> `Graph_lib::Bad_image::~Bad_image()':
> Graph.cpp:(.text._ZN9Graph_lib9Bad_imageD2Ev[_ZN9Graph_lib9Bad_imageD5Ev]+0x1f):
> undefined reference to `Fl_Image::~Fl_Image()'
> Graph.o:(.rodata._ZTIN9Graph_lib9Bad_imageE[_ZTIN9Graph_lib9Bad_imageE]+0x10):
> undefined reference to `typeinfo for Fl_Image' GUI.o: In function
> `Graph_lib::Button::attach(Graph_lib::Window&)': GUI.cpp:(.text+0x5b):
> undefined reference to `Fl_Button::Fl_Button(int, int, int, int, char
> const*)' GUI.o: In function
> `Graph_lib::In_box::attach(Graph_lib::Window&)':
> GUI.cpp:(.text+0x1ed): undefined reference to `Fl_Input::Fl_Input(int,
> int, int, int, char const*)' GUI.o: In function
> `Graph_lib::Out_box::put(int)': GUI.cpp:(.text+0x2cf): undefined
> reference to `Fl_Input_::value(char const*)' GUI.o: In function
> `Graph_lib::Out_box::put(std::string const&)': GUI.cpp:(.text+0x365):
> undefined reference to `Fl_Input_::value(char const*)' GUI.o: In
> function `Graph_lib::Out_box::attach(Graph_lib::Window&)':
> GUI.cpp:(.text+0x3cb): undefined reference to
> `Fl_Output::Fl_Output(int, int, int, int, char const*)'
> Simple_window.o: In function `Simple_window::wait_for_button()':
> Simple_window.cpp:(.text+0x31): undefined reference to `Fl::wait()'
> Simple_window.cpp:(.text+0x48): undefined reference to `Fl::redraw()'
> Window.o: In function `Graph_lib::Window::Window(int, int, std::string
> const&)': Window.cpp:(.text+0x34): undefined reference to
> `Fl_Window::Fl_Window(int, int, char const*)' Window.cpp:(.text+0x9f):
> undefined reference to `Fl_Window::~Fl_Window()' Window.o: In function
> `Graph_lib::Window::Window(Graph_lib::Point, int, int, std::string
> const&)': Window.cpp:(.text+0xf8): undefined reference to
> `Fl_Window::Fl_Window(int, int, int, int, char const*)'
> Window.cpp:(.text+0x163): undefined reference to
> `Fl_Window::~Fl_Window()' Window.o: In function
> `Graph_lib::Window::draw()': Window.cpp:(.text+0x1c7): undefined
> reference to `Fl_Window::draw()' Window.o: In function
> `Graph_lib::Window::attach(Graph_lib::Widget&)':
> Window.cpp:(.text+0x23a): undefined reference to `Fl_Group::begin()'
> Window.cpp:(.text+0x264): undefined reference to `Fl_Group::end()'
> Window.o: In function `Graph_lib::gui_main()':
> Window.cpp:(.text+0x485): undefined reference to `Fl::run()'
> Window.o:(.rodata._ZTVN9Graph_lib6WindowE[_ZTVN9Graph_lib6WindowE]+0x28):
> undefined reference to `Fl_Window::handle(int)'
> Window.o:(.rodata._ZTVN9Graph_lib6WindowE[_ZTVN9Graph_lib6WindowE]+0x30):
> undefined reference to `Fl_Window::resize(int, int, int, int)'
> Window.o:(.rodata._ZTVN9Graph_lib6WindowE[_ZTVN9Graph_lib6WindowE]+0x38):
> undefined reference to `Fl_Window::show()'
> Window.o:(.rodata._ZTVN9Graph_lib6WindowE[_ZTVN9Graph_lib6WindowE]+0x40):
> undefined reference to `Fl_Window::hide()'
> Window.o:(.rodata._ZTVN9Graph_lib6WindowE[_ZTVN9Graph_lib6WindowE]+0x60):
> undefined reference to `Fl_Window::flush()'
> Window.o:(.rodata._ZTIN9Graph_lib6WindowE[_ZTIN9Graph_lib6WindowE]+0x10):
> undefined reference to `typeinfo for Fl_Window' collect2: error: ld
> returned 1 exit status make: *** [hello] error 1
And here is my makefile:
CC=g++
CFLAGS=-c -Wall -std=c++11 `fltk-config --cxxflags --use-images`
LIBS=`fltk-config --ldflags` -lfltk -lfltk_images -ljpeg -lstdc++ -lXfixes -lXext -lpthread -ldl -lm -lX11
all: hello
hello: main.o Graph.o GUI.o Simple_window.o Window.o
$(CC) main.o Graph.o GUI.o Simple_window.o Window.o -o hello
main.o: main.cpp
$(CC) $(CFLAGS) main.cpp $(LIBS)
Graph.o: Graph.cpp
$(CC) $(CFLAGS) Graph.cpp $(LIBS)
GUI.o: GUI.cpp
$(CC) $(CFLAGS) GUI.cpp $(LIBS)
Simple_window.o: Simple_window.cpp
$(CC) $(CFLAGS) Simple_window.cpp $(LIBS)
Window.o: Window.cpp
$(CC) $(CFLAGS) Window.cpp $(LIBS)
clean:
rm -rf *.o hello
Could anyone tell me what I'm doing wrong? I saw in the Web many similar topics, but no answer from them seems to help me.
Thanks so much in advance!
You need to pass LIBS to linker instead of compiler, this would be your makefile:
CC=g++
CFLAGS=-c -Wall -std=c++11 `fltk-config --cxxflags --use-images`
LIBS=`fltk-config --ldflags` -lfltk -lfltk_images -ljpeg -lstdc++ -lXfixes -lXext -lpthread -ldl -lm -lX11
all: hello
hello: main.o Graph.o GUI.o Simple_window.o Window.o
$(CC) main.o Graph.o GUI.o Simple_window.o Window.o -o hello $(LIBS)
main.o: main.cpp
$(CC) $(CFLAGS) main.cpp
Graph.o: Graph.cpp
$(CC) $(CFLAGS) Graph.cpp
GUI.o: GUI.cpp
$(CC) $(CFLAGS) GUI.cpp
Simple_window.o: Simple_window.cpp
$(CC) $(CFLAGS) Simple_window.cpp
Window.o: Window.cpp
$(CC) $(CFLAGS) Window.cpp
clean:
rm -rf *.o hello
i am using proxygen library by facebook to build a simple client example . in a directory i have two object files how do i link them :
i am using:
g++ -std=c++11 -o my_echo CurlClientMain.o CurlClient.o -lproxygenhttpserver -lfolly -lglog -lgflags -pthread
i think i ma missing some linker flag like -lgflags in above example. maybe after including some -someflag will help out compilation . how do i know what all possilble library flags are posiible like the one they have used -lproxyhttpserver.
In short where is all these libs defined or located. i am using ubuntu.
Here is my error message
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()'
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*)'
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 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()'
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*)'
collect2: error: ld returned 1 exit status
how do i know what all possilble library flags are posiible like the one they have used -lproxyhttpserver.
It depends on your compilation environment.
You appear to use the GNU compiler in linux. There is a tool to list all installed shared libraries:
ldconfig -p
You will get a list of lines like this
libpthread.so.0 (libc6,x86-64, OS ABI: Linux 2.6.32) => /lib/x86_64-linux-gnu/libpthread.so.0
Remove the lib prefix and the extension .so.X and you get the name of the library. In this case it's pthread. To link with a libray use the option -lNAME. So, -lpthread in this example.
In short where is all these libs defined or located
The righthand part of the => is the full path to the library.
I've used the already compiled version of openCV for Raspberry Pi. link for anyone who is interested
After trying to compile using this command line
g++ test3.cpp -o test3 -I/usr/local/include/ -lraspicam -lraspicam_cv -L/opt/vc/lib -lmmal -lmmal_core -lmmal_util -I/usr/include -lopencv_core -lopencv_highgui -lopencv_imgproc -lwiringPi -lpthread
I get the following error lines.
//usr/local/lib/libopencv_stitching.so.2.4: undefined reference to `cv::gpu::ensureSizeIsEnough(int, int, int, cv::gpu::GpuMat&)'
//usr/local/lib/libopencv_calib3d.so.2.4: undefined reference to `cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double)'
//usr/local/lib/libopencv_calib3d.so.2.4: undefined reference to `typeinfo for cv::ParallelLoopBody'
//usr/local/lib/libopencv_calib3d.so.2.4: undefined reference to `cv::Mutex::unlock()'
//usr/local/lib/libopencv_calib3d.so.2.4: undefined reference to `cv::Mutex::lock()'
//usr/local/lib/libopencv_ocl.so.2.4: undefined reference to cv::TLSDataContainer::getData() const
//usr/local/lib/libopencv_features2d.so.2.4: undefined reference to cv::AlgorithmInfo::addParam(cv::Algorithm&, char const*, unsigned char&, bool, unsigned char (cv::Algorithm::)(), void (cv::Algorithm::)(unsigned char), std::basic_string, std::allocator > const&)
//usr/local/lib/libopencv_features2d.so.2.4: undefined reference to `cv::AlgorithmInfo::addParam(cv::Algorithm&, char const*, float&, bool, float (cv::Algorithm::)(), void (cv::Algorithm::)(float), std::basic_string, std::allocator > const&)'
//usr/local/lib/libopencv_features2d.so.2.4: undefined reference to `cv::AlgorithmInfo::addParam(cv::Algorithm&, char const*, short&, bool, int (cv::Algorithm::)(), void (cv::Algorithm::)(int), std::basic_string, std::allocator > const&)'
//usr/local/lib/libopencv_calib3d.so.2.4: undefined reference to `cv::Mutex::Mutex()'
//usr/local/lib/libopencv_ocl.so.2.4: undefined reference to `cv::TLSDataContainer::TLSDataContainer()'
//usr/local/lib/libopencv_calib3d.so.2.4: undefined reference to `cv::ParallelLoopBody::~ParallelLoopBody()'
//usr/local/lib/libopencv_calib3d.so.2.4: undefined reference to `cv::Mutex::~Mutex()'
//usr/local/lib/libopencv_ocl.so.2.4: undefined reference to `cv::TLSDataContainer::~TLSDataContainer()'
collect2: ld returned 1 exit status
You have not linked the executable against several libraries that are required by the program
Try using this:
g++ -lpthread `pkg-config opencv --libs` -I/usr/local/include/ -lraspicam -lraspicam_cv -L/opt/vc/lib -lmmal -lmmal_core -lmmal_util -I/usr/include -lwiringPi test3.cpp -o test3
I am absolutely horrible with compiling/linking.
I have tried everything i could find, nothing works.
websockserver.h:516: undefined reference to `qfs_init'
websockserver.h:527: undefined reference to `qfs_read'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Rmdir(char const*)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Remove(char const*)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Open(char const*, int, int, int, int, int, int, unsigned short, signed char, signed char)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Write(int, char const*, unsigned long)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Read(int, char*, unsigned long)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Rename(char const*, char const*, bool)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Tell(int)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Seek(int, long, int)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Stat(char const*, KFS::KfsFileAttr&, bool)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Close(int)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Create(char const*, int, bool, int, int, int, int, bool, unsigned short, signed char, signed char)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Sync(int)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::IsDirectory(char const*)'
./cqfs//libcqfs.so: undefined reference to `KFS::ErrorCodeToStr(int)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::IsFile(char const*)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Exists(char const*)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Mkdir(char const*, unsigned short)'
./cqfs//libcqfs.so: undefined reference to `KFS::KfsClient::Readdir(char const*, std::vector<std::string, std::allocator<std::string> >&)'
./cqfs//libcqfs.so: undefined reference to `KFS::Connect(std::string const&, int)'
collect2: error: ld returned 1 exit status
make: *** [w] Error 1
websockserver.h:514 to 530
long numbytes;
struct cqfs *qfs;
if(!qfs_init(&qfs, "127.0.0.1", 20000))
printf("Failed to init qfs connection\n");
int fd = qfs_open(qfs, "APP.js", O_RDONLY);
if(fd < 0)
printf("Error opening file: %s\n", qfs_error(qfs));
numbytes = (long)qfs_seek(qfs, fd, 0L, SEEK_END);
qfs_seek(qfs, fd, 0L, SEEK_SET);
ret = calloc(numbytes + 1, sizeof(char));
if(qfs_read(qfs, fd, ret, numbytes) < 0)
printf("Error reading file: %s\n", qfs_error(qfs));
qfs_close(qfs, fd);
QFS provides .so and .a of
libqfs_client
libqfs_qcdio
libqfs_io
libqfs_common
libqfs_qcrs
How do i build my wrapper (cqfs.cpp, cqfs.h)?
This is my current command:
g++ -Wall -DBOOST_SP_USE_QUICK_ALLOCATOR -shared -o libcqfs.so cqfs.cpp cqfs.h -fPIC -L./libqfs_client.so -L./libqfs_qcdio.so -lpthread -lrt -L./libqfs_io.so -L./libqfs_common.so -L./libqfs_qcdio.so -lpthread -lz -lrt -lboost_regex-mt -lcrypto -L./libqfs_qcrs.so -lc
based on the example application(not library) provided by Quantcast:
c++ -Wall -DBOOST_SP_USE_QUICK_ALLOCATOR -g CMakeFiles/qfssample.dir/qfssample_main.o -o qfssample -rdynamic ../../src/cc/libclient/libqfs_client.a ../../src/cc/qcdio/libqfs_qcdio.a -lpthread -lrt ../../src/cc/kfsio/libqfs_io.a ../../src/cc/common/libqfs_common.a ../../src/cc/qcdio/libqfs_qcdio.a -lpthread -lz -lrt -lboost_regex-mt -lcrypto ../../src/cc/qcrs/libqfs_qcrs.a
.a or .so did not make a difference
It looks like you are incorrectly using the -L argument to g++. The argument of -L should refer to the directory that contains the libraries, rather than directly referencing them.
To demonstrate, I created a simple example with a Connect and Readdir (I've omitted it for brevity, but let me know if you want to see it). Here is the c++ command I crafted to get it to compile and link correctly:
c++ -Wall -o t -I./build/release/include -L./build/release/lib t.cc -lqfs_client -lqfs_common -lqfs_io -lqfs_qcdio -lqfs_qcrs -lpthread -lboost_regex-mt -lz -lcrypto
One can then run it by specifying the LD_LIBRARY_PATH (DYLD_LIBRARY_PATH on Max OS X):
DYLD_LIBRARY_PATH=$PWD/build/release/lib ./t
.
..
dumpster
test
test2
test3
user
Note that you'll have to LD_LIBRARY_PATH instead of DYLD_LIBRARY_PATH on Linux.
We are actually working on building C bindings for QFS in the main project. Here is the pull request. If you're not comfortable with working directly from the fork (they are very experimental), you can check it out and build with make VERBOSE=1 to see the commands that are actually used to build the components and apply that to build your own bindings.
UPDATE: The C bindings for the QFS API are now available in the master branch.
For example, here is the line that is output to build the shared library on my mac:
/usr/bin/c++ -I/opt/local/include -Wall -DBOOST_SP_USE_QUICK_ALLOCATOR -O2 -g -shared -o libqfsc.dylib -install_name /Users/sday/c/qfs/build/release/src/cc/qfsc/libqfsc.dylib CMakeFiles/qfsc-shared.dir/qfsc.o ../libclient/libqfs_client.dylib ../kfsio/libqfs_io.dylib ../common/libqfs_common.dylib -lpthread -lz ../qcdio/libqfs_qcdio.dylib /usr/local/lib/libboost_regex-mt.dylib /usr/local/lib/libboost_system-mt.dylib ../qcrs/libqfs_qcrs.dylib -lcrypto
Disclaimer: I work for Quantcast.