I've just installed Poco on Ubuntu (by compiling from the code on the git master branch at release 1.9.0). And now I'm trying to compile my HelloWorld.cpp.
This is what I've tried:
g++ -L/usr/local/lib -lPocoFoundation -lPocoUtil -lPocoNet -lPocoNetd -lPocoData -lPocoXML ./helloworld.cpp
This is the helloworld.cpp content:
#include "Poco/Net/HTTPServer.h"
#include "Poco/Net/HTTPRequestHandler.h"
#include "Poco/Net/HTTPRequestHandlerFactory.h"
#include "Poco/Net/HTTPServerRequest.h"
#include "Poco/Net/HTTPServerResponse.h"
#include "Poco/Net/ServerSocket.h"
#include "Poco/Util/ServerApplication.h"
#include <iostream>
using namespace Poco;
using namespace Poco::Net;
using namespace Poco::Util;
class HelloRequestHandler: public HTTPRequestHandler
{
void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response)
{
Application& app = Application::instance();
app.logger().information("Request from %s", request.clientAddress().toString());
response.setChunkedTransferEncoding(true);
response.setContentType("text/html");
response.send()
<< "<html>"
<< "<head><title>Hello</title></head>"
<< "<body><h1>Hello from the POCO Web Server</h1></body>"
<< "</html>";
}
};
class HelloRequestHandlerFactory: public HTTPRequestHandlerFactory
{
HTTPRequestHandler* createRequestHandler(const HTTPServerRequest&)
{
return new HelloRequestHandler;
}
};
class WebServerApp: public ServerApplication
{
void initialize(Application& self)
{
loadConfiguration();
ServerApplication::initialize(self);
}
int main(const std::vector<std::string>&)
{
UInt16 port = static_cast<UInt16>(config().getUInt("port", 8080));
HTTPServer srv(new HelloRequestHandlerFactory, port);
srv.start();
logger().information("HTTP Server started on port %hu.", port);
waitForTerminationRequest();
logger().information("Stopping HTTP Server...");
srv.stop();
return Application::EXIT_OK;
}
};
POCO_SERVER_MAIN(WebServerApp)
I expect by keeping adding the libraries I link in the g++ command line it should eventually allow me to compile the program.
But it seems no matter how many libraries I tried to link I'm still getting the following errors (without eliminating any of the errors with how many libraries I add on the way):
kennyyu#kennyyu-ubuntu:~/poco/myexample$ g++ -L/usr/local/lib -lPocoFoundation -lPocoUtil -lPocoNet -lPocoNetd -lPocoData -lPocoXML ./helloworld.cpp
/tmp/ccWTd1HS.o: In function `main':
helloworld.cpp:(.text+0x53): undefined reference to `Poco::Util::ServerApplication::run(int, char**)'
helloworld.cpp:(.text+0xd1): undefined reference to `Poco::Exception::displayText[abi:cxx11]() const'
/tmp/ccWTd1HS.o: In function `Poco::Net::Impl::IPv4SocketAddressImpl::host() const':
helloworld.cpp:(.text._ZNK4Poco3Net4Impl21IPv4SocketAddressImpl4hostEv[_ZNK4Poco3Net4Impl21IPv4SocketAddressImpl4hostEv]+0x28): undefined reference to `Poco::Net::IPAddress::IPAddress(void const*, unsigned int)'
/tmp/ccWTd1HS.o: In function `Poco::Net::Impl::IPv6SocketAddressImpl::host() const':
helloworld.cpp:(.text._ZNK4Poco3Net4Impl21IPv6SocketAddressImpl4hostEv[_ZNK4Poco3Net4Impl21IPv6SocketAddressImpl4hostEv]+0x2e): undefined reference to `Poco::Net::IPAddress::IPAddress(void const*, unsigned int, unsigned int)'
/tmp/ccWTd1HS.o: In function `Poco::ReferenceCounter::ReferenceCounter()':
helloworld.cpp:(.text._ZN4Poco16ReferenceCounterC2Ev[_ZN4Poco16ReferenceCounterC5Ev]+0x19): undefined reference to `Poco::AtomicCounter::AtomicCounter(int)'
/tmp/ccWTd1HS.o: In function `Poco::Logger::log(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Poco::Message::Priority)':
helloworld.cpp:(.text._ZN4Poco6Logger3logERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENS_7Message8PriorityE[_ZN4Poco6Logger3logERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENS_7Message8PriorityE]+0xa0): undefined reference to `Poco::Message::Message(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Poco::Message::Priority)'
helloworld.cpp:(.text._ZN4Poco6Logger3logERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENS_7Message8PriorityE[_ZN4Poco6Logger3logERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENS_7Message8PriorityE]+0xbe): undefined reference to `Poco::Message::~Message()'
helloworld.cpp:(.text._ZN4Poco6Logger3logERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENS_7Message8PriorityE[_ZN4Poco6Logger3logERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENS_7Message8PriorityE]+0xd2): undefined reference to `Poco::Message::~Message()'
/tmp/ccWTd1HS.o: In function `Poco::Logger::information(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Poco::Any const&)':
helloworld.cpp:(.text._ZN4Poco6Logger11informationERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKNS_3AnyE[_ZN4Poco6Logger11informationERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKNS_3AnyE]+0x37): undefined reference to `Poco::format(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Poco::Any const&)'
/tmp/ccWTd1HS.o: In function `Poco::Util::Application::logger() const':
helloworld.cpp:(.text._ZNK4Poco4Util11Application6loggerEv[_ZNK4Poco4Util11Application6loggerEv]+0x30): undefined reference to `Poco::Bugcheck::nullPointer(char const*, char const*, int)'
/tmp/ccWTd1HS.o: In function `Poco::Util::Application::instance()':
helloworld.cpp:(.text._ZN4Poco4Util11Application8instanceEv[_ZN4Poco4Util11Application8instanceEv]+0x7): undefined reference to `Poco::Util::Application::_pInstance'
helloworld.cpp:(.text._ZN4Poco4Util11Application8instanceEv[_ZN4Poco4Util11Application8instanceEv]+0x24): undefined reference to `Poco::Bugcheck::nullPointer(char const*, char const*, int)'
helloworld.cpp:(.text._ZN4Poco4Util11Application8instanceEv[_ZN4Poco4Util11Application8instanceEv]+0x2b): undefined reference to `Poco::Util::Application::_pInstance'
/tmp/ccWTd1HS.o: In function `HelloRequestHandler::handleRequest(Poco::Net::HTTPServerRequest&, Poco::Net::HTTPServerResponse&)':
helloworld.cpp:(.text._ZN19HelloRequestHandler13handleRequestERN4Poco3Net17HTTPServerRequestERNS1_18HTTPServerResponseE[_ZN19HelloRequestHandler13handleRequestERN4Poco3Net17HTTPServerRequestERNS1_18HTTPServerResponseE]+0x73): undefined reference to `Poco::Net::SocketAddress::toString[abi:cxx11]() const'
helloworld.cpp:(.text._ZN19HelloRequestHandler13handleRequestERN4Poco3Net17HTTPServerRequestERNS1_18HTTPServerResponseE[_ZN19HelloRequestHandler13handleRequestERN4Poco3Net17HTTPServerRequestERNS1_18HTTPServerResponseE]+0x100): undefined reference to `Poco::Net::HTTPMessage::setChunkedTransferEncoding(bool)'
helloworld.cpp:(.text._ZN19HelloRequestHandler13handleRequestERN4Poco3Net17HTTPServerRequestERNS1_18HTTPServerResponseE[_ZN19HelloRequestHandler13handleRequestERN4Poco3Net17HTTPServerRequestERNS1_18HTTPServerResponseE]+0x139): undefined reference to `Poco::Net::HTTPMessage::setContentType(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/tmp/ccWTd1HS.o: In function `HelloRequestHandler::HelloRequestHandler()':
helloworld.cpp:(.text._ZN19HelloRequestHandlerC2Ev[_ZN19HelloRequestHandlerC5Ev]+0x14): undefined reference to `Poco::Net::HTTPRequestHandler::HTTPRequestHandler()'
/tmp/ccWTd1HS.o: In function `WebServerApp::initialize(Poco::Util::Application&)':
helloworld.cpp:(.text._ZN12WebServerApp10initializeERN4Poco4Util11ApplicationE[_ZN12WebServerApp10initializeERN4Poco4Util11ApplicationE]+0x1d): undefined reference to `Poco::Util::Application::loadConfiguration(int)'
helloworld.cpp:(.text._ZN12WebServerApp10initializeERN4Poco4Util11ApplicationE[_ZN12WebServerApp10initializeERN4Poco4Util11ApplicationE]+0x30): undefined reference to `Poco::Util::Application::initialize(Poco::Util::Application&)'
/tmp/ccWTd1HS.o: In function `HelloRequestHandlerFactory::HelloRequestHandlerFactory()':
helloworld.cpp:(.text._ZN26HelloRequestHandlerFactoryC2Ev[_ZN26HelloRequestHandlerFactoryC5Ev]+0x14): undefined reference to `Poco::Net::HTTPRequestHandlerFactory::HTTPRequestHandlerFactory()'
/tmp/ccWTd1HS.o: In function `WebServerApp::main(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&)':
helloworld.cpp:(.text._ZN12WebServerApp4mainERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS6_EE[_ZN12WebServerApp4mainERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS6_EE]+0x7c): undefined reference to `Poco::Util::AbstractConfiguration::getUInt(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int) const'
helloworld.cpp:(.text._ZN12WebServerApp4mainERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS6_EE[_ZN12WebServerApp4mainERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS6_EE]+0xb6): undefined reference to `Poco::Net::HTTPServerParams::HTTPServerParams()'
helloworld.cpp:(.text._ZN12WebServerApp4mainERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS6_EE[_ZN12WebServerApp4mainERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS6_EE]+0x11d): undefined reference to `Poco::Net::HTTPServer::HTTPServer(Poco::SharedPtr<Poco::Net::HTTPRequestHandlerFactory, Poco::ReferenceCounter, Poco::ReleasePolicy<Poco::Net::HTTPRequestHandlerFactory> >, unsigned short, Poco::AutoPtr<Poco::Net::HTTPServerParams>)'
helloworld.cpp:(.text._ZN12WebServerApp4mainERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS6_EE[_ZN12WebServerApp4mainERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS6_EE]+0x14a): undefined reference to `Poco::Net::TCPServer::start()'
helloworld.cpp:(.text._ZN12WebServerApp4mainERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS6_EE[_ZN12WebServerApp4mainERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS6_EE]+0x1f6): undefined reference to `Poco::Util::ServerApplication::waitForTerminationRequest()'
helloworld.cpp:(.text._ZN12WebServerApp4mainERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS6_EE[_ZN12WebServerApp4mainERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS6_EE]+0x273): undefined reference to `Poco::Net::TCPServer::stop()'
helloworld.cpp:(.text._ZN12WebServerApp4mainERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS6_EE[_ZN12WebServerApp4mainERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS6_EE]+0x287): undefined reference to `Poco::Net::HTTPServer::~HTTPServer()'
helloworld.cpp:(.text._ZN12WebServerApp4mainERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS6_EE[_ZN12WebServerApp4mainERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS6_EE]+0x3a4): undefined reference to `Poco::Net::HTTPServer::~HTTPServer()'
/tmp/ccWTd1HS.o: In function `WebServerApp::WebServerApp()':
helloworld.cpp:(.text._ZN12WebServerAppC2Ev[_ZN12WebServerAppC5Ev]+0x14): undefined reference to `Poco::Util::ServerApplication::ServerApplication()'
/tmp/ccWTd1HS.o: In function `Poco::ReferenceCounter::~ReferenceCounter()':
helloworld.cpp:(.text._ZN4Poco16ReferenceCounterD2Ev[_ZN4Poco16ReferenceCounterD5Ev]+0x14): undefined reference to `Poco::AtomicCounter::~AtomicCounter()'
/tmp/ccWTd1HS.o:(.data.rel.ro._ZTV12WebServerApp[_ZTV12WebServerApp]+0x20): undefined reference to `Poco::Util::Application::name() const'
/tmp/ccWTd1HS.o:(.data.rel.ro._ZTV12WebServerApp[_ZTV12WebServerApp]+0x30): undefined reference to `Poco::Util::Application::uninitialize()'
/tmp/ccWTd1HS.o:(.data.rel.ro._ZTV12WebServerApp[_ZTV12WebServerApp]+0x38): undefined reference to `Poco::Util::Application::reinitialize(Poco::Util::Application&)'
/tmp/ccWTd1HS.o:(.data.rel.ro._ZTV12WebServerApp[_ZTV12WebServerApp]+0x40): undefined reference to `Poco::Util::ServerApplication::defineOptions(Poco::Util::OptionSet&)'
/tmp/ccWTd1HS.o:(.data.rel.ro._ZTV12WebServerApp[_ZTV12WebServerApp]+0x48): undefined reference to `Poco::Util::ServerApplication::run()'
/tmp/ccWTd1HS.o:(.data.rel.ro._ZTV12WebServerApp[_ZTV12WebServerApp]+0x50): undefined reference to `Poco::Util::Application::handleOption(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/tmp/ccWTd1HS.o: In function `WebServerApp::~WebServerApp()':
helloworld.cpp:(.text._ZN12WebServerAppD2Ev[_ZN12WebServerAppD5Ev]+0x22): undefined reference to `Poco::Util::ServerApplication::~ServerApplication()'
/tmp/ccWTd1HS.o: In function `HelloRequestHandlerFactory::~HelloRequestHandlerFactory()':
helloworld.cpp:(.text._ZN26HelloRequestHandlerFactoryD2Ev[_ZN26HelloRequestHandlerFactoryD5Ev]+0x22): undefined reference to `Poco::Net::HTTPRequestHandlerFactory::~HTTPRequestHandlerFactory()'
/tmp/ccWTd1HS.o: In function `HelloRequestHandler::~HelloRequestHandler()':
helloworld.cpp:(.text._ZN19HelloRequestHandlerD2Ev[_ZN19HelloRequestHandlerD5Ev]+0x22): undefined reference to `Poco::Net::HTTPRequestHandler::~HTTPRequestHandler()'
/tmp/ccWTd1HS.o:(.data.rel.ro._ZTVN4Poco3Net4Impl21IPv6SocketAddressImplE[_ZTVN4Poco3Net4Impl21IPv6SocketAddressImplE]+0x50): undefined reference to `Poco::Net::Impl::IPv6SocketAddressImpl::toString[abi:cxx11]() const'
/tmp/ccWTd1HS.o: In function `Poco::Net::Impl::IPv6SocketAddressImpl::~IPv6SocketAddressImpl()':
helloworld.cpp:(.text._ZN4Poco3Net4Impl21IPv6SocketAddressImplD2Ev[_ZN4Poco3Net4Impl21IPv6SocketAddressImplD5Ev]+0x22): undefined reference to `Poco::Net::Impl::SocketAddressImpl::~SocketAddressImpl()'
/tmp/ccWTd1HS.o:(.data.rel.ro._ZTVN4Poco3Net4Impl21IPv4SocketAddressImplE[_ZTVN4Poco3Net4Impl21IPv4SocketAddressImplE]+0x50): undefined reference to `Poco::Net::Impl::IPv4SocketAddressImpl::toString[abi:cxx11]() const'
/tmp/ccWTd1HS.o: In function `Poco::Net::Impl::IPv4SocketAddressImpl::~IPv4SocketAddressImpl()':
helloworld.cpp:(.text._ZN4Poco3Net4Impl21IPv4SocketAddressImplD2Ev[_ZN4Poco3Net4Impl21IPv4SocketAddressImplD5Ev]+0x22): undefined reference to `Poco::Net::Impl::SocketAddressImpl::~SocketAddressImpl()'
/tmp/ccWTd1HS.o:(.data.rel.ro._ZTI12WebServerApp[_ZTI12WebServerApp]+0x10): undefined reference to `typeinfo for Poco::Util::ServerApplication'
/tmp/ccWTd1HS.o:(.data.rel.ro._ZTI26HelloRequestHandlerFactory[_ZTI26HelloRequestHandlerFactory]+0x10): undefined reference to `typeinfo for Poco::Net::HTTPRequestHandlerFactory'
/tmp/ccWTd1HS.o:(.data.rel.ro._ZTI19HelloRequestHandler[_ZTI19HelloRequestHandler]+0x10): undefined reference to `typeinfo for Poco::Net::HTTPRequestHandler'
/tmp/ccWTd1HS.o:(.data.rel.ro._ZTIN4Poco3Net4Impl21IPv6SocketAddressImplE[_ZTIN4Poco3Net4Impl21IPv6SocketAddressImplE]+0x10): undefined reference to `typeinfo for Poco::Net::Impl::SocketAddressImpl'
/tmp/ccWTd1HS.o:(.data.rel.ro._ZTIN4Poco3Net4Impl21IPv4SocketAddressImplE[_ZTIN4Poco3Net4Impl21IPv4SocketAddressImplE]+0x10): undefined reference to `typeinfo for Poco::Net::Impl::SocketAddressImpl'
/tmp/ccWTd1HS.o:(.data.rel.local.DW.ref._ZTIN4Poco9ExceptionE[DW.ref._ZTIN4Poco9ExceptionE]+0x0): undefined reference to `typeinfo for Poco::Exception'
collect2: error: ld returned 1 exit status
kennyyu#kennyyu-ubuntu:~/poco/myexample$
kennyyu#kennyyu-ubuntu:~/poco/myexample$ ls /usr/local/lib/libPoco*.so
/usr/local/lib/libPocoCppParserd.so /usr/local/lib/libPocoDataMySQL.so /usr/local/lib/libPocoDataSQLited.so /usr/local/lib/libPocoFoundationd.so /usr/local/lib/libPocoMongoDBd.so /usr/local/lib/libPocoPDFd.so /usr/local/lib/libPocoUtild.so /usr/local/lib/libPocoZipd.so
/usr/local/lib/libPocoCppParser.so /usr/local/lib/libPocoDataODBCd.so /usr/local/lib/libPocoDataSQLite.so /usr/local/lib/libPocoFoundation.so /usr/local/lib/libPocoMongoDB.so /usr/local/lib/libPocoPDF.so /usr/local/lib/libPocoUtil.so /usr/local/lib/libPocoZip.so
/usr/local/lib/libPocoDatad.so /usr/local/lib/libPocoDataODBC.so /usr/local/lib/libPocoEncodingsd.so /usr/local/lib/libPocoJSONd.so /usr/local/lib/libPocoNetd.so /usr/local/lib/libPocoRedisd.so /usr/local/lib/libPocoXMLd.so
/usr/local/lib/libPocoDataMySQLd.so /usr/local/lib/libPocoData.so /usr/local/lib/libPocoEncodings.so /usr/local/lib/libPocoJSON.so /usr/local/lib/libPocoNet.so /usr/local/lib/libPocoRedis.so /usr/local/lib/libPocoXML.so
kennyyu#kennyyu-ubuntu:~/poco/myexample$
Can someone please shed me some light?
This worked for me in Ubuntu 19.10.
sudo apt install libpoco-dev
(All of the Poco libraries get installed with that.)
Create helloworld.cpp with contents from OP.
Compile with:
g++ helloworld.cpp -o helloworld.o -lPocoFoundation -lPocoNet -lPocoUtil
If that still doesn't work, you can include the location where the Poco .h files are with the -I option, and where the Poco .so files are with the -L option.
Find where the Poco .so files are located:
sudo find / -name "libPoco*.so" 2>/dev/null
/usr/lib/x86_64-linux-gnu/libPocoFoundation.so
...
sudo find / -name "ServerSocket.h" 2>/dev/null
/usr/include/Poco/Net/ServerSocket.h
The compile statement then becomes:
g++ -I/usr/include/Poco/ helloworld.cpp -o helloworld.o -L/usr/lib/x86_64-linux-gnu/ -lPocoFoundation -lPocoNet -lPocoUtil
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 have correctly installed crfsuite from source (https://github.com/downloads/chokkan/crfsuite/crfsuite-0.12.tar.gz).
But when I try to compile a very simple code, it seems that I have missed something.
Here is the code:
#include "crfsuite.hpp"
using namespace CRFSuite;
int main(int argc, char *argv[])
{
Tagger tagger;
}
Here's the command line to compile:
g++ -L/usr/local/lib -I/usr/local/include -lcrfsuite tagging.cpp
and the error:
/tmp/ccIkvCFv.o: In function `CRFSuite::Trainer::Trainer()':
tagging.cpp:(.text+0x48): undefined reference to `crfsuite_data_init'
/tmp/ccIkvCFv.o: In function `CRFSuite::Trainer::init()':
tagging.cpp:(.text+0x149): undefined reference to `crfsuite_create_instance'
tagging.cpp:(.text+0x1b7): undefined reference to `crfsuite_create_instance'
/tmp/ccIkvCFv.o: In function `CRFSuite::Trainer::clear()':
tagging.cpp:(.text+0x2dd): undefined reference to `crfsuite_data_finish'
tagging.cpp:(.text+0x2ed): undefined reference to `crfsuite_data_init'
/tmp/ccIkvCFv.o: In function `CRFSuite::Trainer::append(std::vector<std::vector<CRFSuite::Attribute, std::allocator<CRFSuite::Attribute> >, std::allocator<std::vector<CRFSuite::Attribute, std::allocator<CRFSuite::Attribute> > > > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, int)':
tagging.cpp:(.text+0x495): undefined reference to `crfsuite_instance_init_n'
tagging.cpp:(.text+0x51f): undefined reference to `crfsuite_item_init_n'
tagging.cpp:(.text+0x69b): undefined reference to `crfsuite_data_append'
tagging.cpp:(.text+0x6aa): undefined reference to `crfsuite_instance_finish'
/tmp/ccIkvCFv.o: In function `CRFSuite::Trainer::select(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
tagging.cpp:(.text+0x7e9): undefined reference to `crfsuite_create_instance'
/tmp/ccIkvCFv.o: In function `CRFSuite::Tagger::open(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
tagging.cpp:(.text+0x11a0): undefined reference to `crfsuite_create_instance_from_file'
/tmp/ccIkvCFv.o: In function `CRFSuite::Tagger::set(std::vector<std::vector<CRFSuite::Attribute, std::allocator<CRFSuite::Attribute> >, std::allocator<std::vector<CRFSuite::Attribute, std::allocator<CRFSuite::Attribute> > > > const&)':
tagging.cpp:(.text+0x16c6): undefined reference to `crfsuite_instance_init_n'
tagging.cpp:(.text+0x1731): undefined reference to `crfsuite_item_init'
tagging.cpp:(.text+0x17e1): undefined reference to `crfsuite_attribute_set'
tagging.cpp:(.text+0x17f4): undefined reference to `crfsuite_item_append_attribute'
tagging.cpp:(.text+0x1854): undefined reference to `crfsuite_instance_finish'
tagging.cpp:(.text+0x18ac): undefined reference to `crfsuite_instance_finish'
collect2: error: ld returned 1 exit status
The paths are correct (/usr/local/lib, /usr/local/include)
The order of arguments matters. The library should go after your cpp file:
g++ -L/usr/local/lib -I/usr/local/include tagging.cpp -lcrfsuite
See the answer Why does the order in which libraries are linked sometimes cause errors in GCC? for more information.
I am cross-compiling OpenCV libraries (2.4.9) and Raspicam (0.1.3) in Eclipse CDT IDE for Raspberry Pi. I am trying to compile a basic application that looks as the following:
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/opencv.hpp>
#include <raspicam.h>
#include <raspicam_cv.h>
using namespace std;
using namespace cv;
int main()
{
....
namedWindow(output_window_name, CV_WINDOW_AUTOSIZE);
namedWindow(grayscale_window_name, 100);
namedWindow(thresholded_window_name, 100);
namedWindow(contours_window_name, 100);
moveWindow(grayscale_window_name, 20,20);
moveWindow(thresholded_window_name, 20, 250);
moveWindow(contours_window_name, 20, 600);
vector<int> compression_params;
compression_params.push_back(CV_IMWRITE_JPEG_QUALITY);
compression_params.push_back(100);
raspicam::RaspiCam_Cv Camera;
....
}
To compile I made sure that libopencv_*.so files are in the cross compilation sysroot and linked in Eclipse using -l flags such as -lopencv_core -lopencv_highgui etc. I also included every include/ folder in sources using -I flag in Eclipse Build Settings.
Inclusion using #include and namespace declarations do not result in any errors.
Target building looks like this in the console:
arm-linux-gnueabihf-g++
-L"C:\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\lib"
-L"C:/SysGCC/Raspberry/arm-linux-gnueabihf/sysroot/usr/lib/arm-linux-gnueabihf"
-L"C:\rpi-eclipse\workspace\RaspberryTest\libbluetooth"
-L"C:\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\lib"
-Wl,-rpath-link,"C:\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\lib\arm-linux-gnueabihf"
-o "RaspberryTest" ./src/<ALL OBJS>
-lwiringPi
-lopencv_calib3d
-lopencv_core
-lopencv_features2d
-lopencv_flann
-lopencv_highgui
-lopencv_imgproc
-lopencv_ml
-lopencv_objdetect
-lopencv_video
-lbluetooth
-lpthread
-lwiringPiDev
However, the following errors are there:
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:115: undefined reference to `cv::namedWindow(std::string const&, int)'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:116: undefined reference to `cv::namedWindow(std::string const&, int)'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:117: undefined reference to `cv::namedWindow(std::string const&, int)'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:118: undefined reference to `cv::namedWindow(std::string const&, int)'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:120: undefined reference to `cv::moveWindow(std::string const&, int, int)'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:121: undefined reference to `cv::moveWindow(std::string const&, int, int)'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:122: undefined reference to `cv::moveWindow(std::string const&, int, int)'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:129: undefined reference to `raspicam::RaspiCam_Cv::RaspiCam_Cv()'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:131: undefined reference to `raspicam::RaspiCam_Cv::open()'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:194: undefined reference to `raspicam::RaspiCam_Cv::grab()'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:195: undefined reference to `raspicam::RaspiCam_Cv::retrieve(cv::Mat&)'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:208: undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:208: undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:211: undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:211: undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:215: undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:215: undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:219: undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:219: undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:220: undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:220: undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:220: undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:224: undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:224: undefined reference to `cv::floodFill(cv::_OutputArray const&, cv::Point_<int>, cv::Scalar_<double>, cv::Rect_<int>*, cv::Scalar_<double>, cv::Scalar_<double>, int)'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:228: undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:228: undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:233: undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:233: undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:238: undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:238: undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:240: undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:240: undefined reference to `cv::findContours(cv::_OutputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, int, int, cv::Point_<int>)'
C:\rpi-eclipse\workspace\RaspberryTest\Debug/../src/tasks/image_processing_task.cpp:129: undefined reference to `raspicam::RaspiCam_Cv::~RaspiCam_Cv()'
./src/tasks/image_processing_task.o: In function `cv::Mat::clone() const':
C:\rpi-eclipse\workspace\RaspberryTest\opencv-2.4.9\modules\core\include/opencv2/core/mat.hpp:335: undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
./src/tasks/image_processing_task.o: In function `cv::_InputArray::_InputArray(cv::Scalar_<double> const&)':
C:\rpi-eclipse\workspace\RaspberryTest\opencv-2.4.9\modules\core\include/opencv2/core/mat.hpp:1137: undefined reference to `vtable for cv::_InputArray'
./src/tasks/image_processing_task.o: In function `cv::_OutputArray::_OutputArray<cv::Point_<int> >(std::vector<std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > >, std::allocator<std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > > > >&)':
C:\rpi-eclipse\workspace\RaspberryTest\opencv-2.4.9\modules\core\include/opencv2/core/mat.hpp:1145: undefined reference to `vtable for cv::_OutputArray'
./src/tasks/image_processing_task.o: In function `cv::_OutputArray::_OutputArray<cv::Vec<int, 4> >(std::vector<cv::Vec<int, 4>, std::allocator<cv::Vec<int, 4> > >&)':
C:\rpi-eclipse\workspace\RaspberryTest\opencv-2.4.9\modules\core\include/opencv2/core/mat.hpp:1143: undefined reference to `vtable for cv::_OutputArray'
./src/tasks/image_processing_task.o: In function `cv::_InputArray::_InputArray<cv::Point_<int> >(std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > > const&)':
C:\rpi-eclipse\workspace\RaspberryTest\opencv-2.4.9\modules\core\include/opencv2/core/mat.hpp:1122: undefined reference to `vtable for cv::_InputArray'
./src/tasks/image_processing_task.o: In function `cv::_OutputArray::_OutputArray<cv::Point_<int> >(std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > >&)':
C:\rpi-eclipse\workspace\RaspberryTest\opencv-2.4.9\modules\core\include/opencv2/core/mat.hpp:1143: undefined reference to `vtable for cv::_OutputArray'
./src/tasks/image_processing_task.o: In function `cv::_InputArray::_InputArray<cv::Point_<int> >(std::vector<std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > >, std::allocator<std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > > > > const&)':
C:\rpi-eclipse\workspace\RaspberryTest\opencv-2.4.9\modules\core\include/opencv2/core/mat.hpp:1125: undefined reference to `vtable for cv::_InputArray'
./src/tasks/image_processing_task.o: In function `cv::_InputArray::_InputArray<cv::Vec<int, 4> >(std::vector<cv::Vec<int, 4>, std::allocator<cv::Vec<int, 4> > > const&)':
C:\rpi-eclipse\workspace\RaspberryTest\opencv-2.4.9\modules\core\include/opencv2/core/mat.hpp:1122: undefined reference to `vtable for cv::_InputArray'
collect2.exe: error: ld returned 1 exit status
make: *** [RaspberryTest] Error 1
This indicates that I have two type of errors.
1-) undefined reference (for functions)
2-) undefined reference to vtable` (Related to virtual functions I believe)
In order to overcome this problem, I feel like I have to change STL/C standards, but do not know what to do exactly. Also, the fact that libraries are compiled and included correctly but there are still undefined references is really weird to me.
Any guidance regarding how to solve this problem is greately appreciated.
Thanks in advance.
What are the ways to run apache qpid c++ helloworld example without make and by using g++ i need to create an helloworld.o object file how to do these?
g++ -I ./includes/ -o m hello_world.cpp
/tmp/cc9Jao8f.o: In function `main':
hello_world.cpp:(.text+0x169): undefined reference to `qpid::messaging::Connection::Connection(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
hello_world.cpp:(.text+0x178): undefined reference to `qpid::messaging::Connection::open()'
hello_world.cpp:(.text+0x1a1): undefined reference to `qpid::messaging::Connection::createSession(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
hello_world.cpp:(.text+0x1e8): undefined reference to `qpid::messaging::Session::createReceiver(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
hello_world.cpp:(.text+0x205): undefined reference to `qpid::messaging::Session::createSender(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
hello_world.cpp:(.text+0x239): undefined reference to `qpid::messaging::Message::Message(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
hello_world.cpp:(.text+0x254): undefined reference to `qpid::messaging::Sender::send(qpid::messaging::Message const&, bool)'
hello_world.cpp:(.text+0x267): undefined reference to `qpid::messaging::Message::~Message()'
hello_world.cpp:(.text+0x27b): undefined reference to `qpid::messaging::Message::~Message()'
hello_world.cpp:(.text+0x2d6): undefined reference to `qpid::messaging::Duration::SECOND'
hello_world.cpp:(.text+0x2db): undefined reference to `qpid::messaging::operator*(qpid::messaging::Duration const&, unsigned long)'
hello_world.cpp:(.text+0x2f7): undefined reference to `qpid::messaging::Receiver::fetch(qpid::messaging::Duration)'
hello_world.cpp:(.text+0x30d): undefined reference to `qpid::messaging::Message::getContent() const'
hello_world.cpp:(.text+0x366): undefined reference to `qpid::messaging::Session::acknowledge(bool)'
hello_world.cpp:(.text+0x375): undefined reference to `qpid::messaging::Connection::close()'
hello_world.cpp:(.text+0x389): undefined reference to `qpid::messaging::Message::~Message()'
hello_world.cpp:(.text+0x39f): undefined reference to `qpid::messaging::Message::~Message()'
hello_world.cpp:(.text+0x3bb): undefined reference to `qpid::messaging::Sender::~Sender()'
hello_world.cpp:(.text+0x3d2): undefined reference to `qpid::messaging::Sender::~Sender()'
hello_world.cpp:(.text+0x3e8): undefined reference to `qpid::messaging::Receiver::~Receiver()'
hello_world.cpp:(.text+0x3ff): undefined reference to `qpid::messaging::Receiver::~Receiver()'
hello_world.cpp:(.text+0x415): undefined reference to `qpid::messaging::Session::~Session()'
hello_world.cpp:(.text+0x42c): undefined reference to `qpid::messaging::Session::~Session()'
hello_world.cpp:(.text+0x483): undefined reference to `qpid::messaging::Connection::close()'
hello_world.cpp:(.text+0x4b5): undefined reference to `qpid::messaging::Connection::~Connection()'
hello_world.cpp:(.text+0x4cc): undefined reference to `qpid::messaging::Connection::~Connection()'
collect2: ld returned 1 exit status
You just need to link against the library. If the library is called libqpid.so for example, you would add -lqpid to your build command.
Newbie question... I'm trying out Boost for the first time because I want to test drive the Boost Log library. I built this test program...
#include <boost/log/trivial.hpp>
#include <iostream>
int fibonacci(int num) {
int i;
int a = 1;
int b = 1;
for (i = 2; i <= num; ++i) {
BOOST_LOG_TRIVIAL(info) << "Iteration " << i << " (a = " << a << ", b = " << b << ")...";
b = a + b;
a = b - a;
}
return a;
}
int main() {
std::cout << "8th fibonacci number: " << fibonacci(8) << std::endl;
return 0;
}
Compile data:
**** Build of configuration Debug for project LoggingCpp ****
make all
Building file: ../main.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -lpthread -MMD -MP -MF"main.d" -MT"main.d" -o"main.o" "../main.cpp"
Finished building: ../main.cpp
Building target: LoggingCpp
Invoking: GCC C++ Linker
g++ -lpthread -o"LoggingCpp" ./main.o
./main.o: In function `~basic_logger':
/usr/include/boost/log/sources/basic_logger.hpp:90: undefined reference to `boost::log_mt_posix::basic_attribute_set<char>::~basic_attribute_set()'
./main.o: In function `boost::log_mt_posix::trivial::logger::construct_logger()':
/usr/include/boost/log/trivial.hpp:102: undefined reference to `boost::log_mt_posix::trivial::aux::init()'
./main.o: In function `void boost::call_once<void (*)()>(boost::once_flag&, void (*)())':
/usr/include/boost/thread/pthread/once.hpp:51: undefined reference to `boost::detail::get_once_per_thread_epoch()'
/usr/include/boost/thread/pthread/once.hpp:55: undefined reference to `boost::detail::once_epoch_mutex'
/usr/include/boost/thread/pthread/once.hpp:66: undefined reference to `boost::detail::once_epoch_mutex'
/usr/include/boost/thread/pthread/once.hpp:77: undefined reference to `boost::detail::once_global_epoch'
/usr/include/boost/thread/pthread/once.hpp:77: undefined reference to `boost::detail::once_global_epoch'
/usr/include/boost/thread/pthread/once.hpp:77: undefined reference to `boost::detail::once_global_epoch'
/usr/include/boost/thread/pthread/once.hpp:78: undefined reference to `boost::detail::once_epoch_cv'
/usr/include/boost/thread/pthread/once.hpp:84: undefined reference to `boost::detail::once_epoch_mutex'
/usr/include/boost/thread/pthread/once.hpp:84: undefined reference to `boost::detail::once_epoch_cv'
/usr/include/boost/thread/pthread/once.hpp:88: undefined reference to `boost::detail::once_global_epoch'
/usr/include/boost/thread/pthread/once.hpp:73: undefined reference to `boost::detail::once_epoch_cv'
./main.o: In function `record_pump':
/usr/include/boost/log/sources/record_ostream.hpp:293: undefined reference to `boost::log_mt_posix::aux::stream_provider<char>::allocate_compound(boost::log_mt_posix::basic_record<char> const&)'
./main.o: In function `~auto_release':
/usr/include/boost/log/sources/record_ostream.hpp:280: undefined reference to `boost::log_mt_posix::aux::stream_provider<char>::release_compound(boost::log_mt_posix::aux::stream_provider<char>::stream_compound*)'
./main.o: In function `boost::log_mt_posix::sources::aux::logger_singleton<boost::log_mt_posix::trivial::logger>::init_instance()':
/usr/include/boost/log/sources/global_logger_storage.hpp:126: undefined reference to `boost::log_mt_posix::sources::aux::global_storage<char>::get_or_init(std::type_info const&, boost::function0<boost::shared_ptr<boost::log_mt_posix::sources::aux::logger_holder_base> > const&)'
/usr/include/boost/log/sources/global_logger_storage.hpp:147: undefined reference to `boost::log_mt_posix::odr_violation::throw_(char const*, unsigned long, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
./main.o: In function `boost::log_mt_posix::sources::aux::severity_level<boost::log_mt_posix::trivial::severity_level>::set_value(boost::log_mt_posix::trivial::severity_level)':
/usr/include/boost/log/sources/severity_feature.hpp:95: undefined reference to `boost::log_mt_posix::sources::aux::set_severity_level(int)'
./main.o: In function `boost::log_mt_posix::basic_record<char> boost::log_mt_posix::sources::basic_logger<char, boost::log_mt_posix::sources::severity_logger_mt<boost::log_mt_posix::trivial::severity_level>, boost::log_mt_posix::sources::multi_thread_model<boost::log_mt_posix::aux::light_rw_mutex> >::open_record_unlocked<boost::parameter::aux::tagged_argument<boost::log_mt_posix::keywords::tag::severity, boost::log_mt_posix::trivial::severity_level const> >(boost::parameter::aux::tagged_argument<boost::log_mt_posix::keywords::tag::severity, boost::log_mt_posix::trivial::severity_level const> const&)':
/usr/include/boost/log/sources/basic_logger.hpp:269: undefined reference to `boost::log_mt_posix::basic_core<char>::open_record(boost::log_mt_posix::basic_attribute_set<char> const&)'
./main.o: In function `boost::log_mt_posix::sources::basic_logger<char, boost::log_mt_posix::sources::severity_logger_mt<boost::log_mt_posix::trivial::severity_level>, boost::log_mt_posix::sources::multi_thread_model<boost::log_mt_posix::aux::light_rw_mutex> >::push_record_unlocked(boost::log_mt_posix::basic_record<char> const&)':
/usr/include/boost/log/sources/basic_logger.hpp:280: undefined reference to `boost::log_mt_posix::basic_core<char>::push_record(boost::log_mt_posix::basic_record<char> const&)'
./main.o: In function `basic_logger<boost::parameter::aux::tagged_argument<boost::log_mt_posix::keywords::tag::severity, const boost::log_mt_posix::trivial::severity_level> >':
/usr/include/boost/log/sources/basic_logger.hpp:145: undefined reference to `boost::log_mt_posix::basic_core<char>::get()'
/usr/include/boost/log/sources/basic_logger.hpp:145: undefined reference to `boost::log_mt_posix::basic_attribute_set<char>::basic_attribute_set()'
./main.o: In function `~pair':
/usr/include/c++/4.5/bits/stl_pair.h:72: undefined reference to `boost::log_mt_posix::basic_slim_string<char, std::char_traits<char> >::~basic_slim_string()'
/usr/include/c++/4.5/bits/stl_pair.h:72: undefined reference to `boost::log_mt_posix::basic_slim_string<char, std::char_traits<char> >::~basic_slim_string()'
./main.o: In function `basic_logger':
/usr/include/boost/log/sources/basic_logger.hpp:135: undefined reference to `boost::log_mt_posix::basic_core<char>::get()'
/usr/include/boost/log/sources/basic_logger.hpp:135: undefined reference to `boost::log_mt_posix::basic_attribute_set<char>::basic_attribute_set(boost::log_mt_posix::basic_attribute_set<char> const&)'
./main.o: In function `boost::log_mt_posix::basic_attribute_set<char>::reference_proxy::operator=(boost::shared_ptr<boost::log_mt_posix::attribute> const&) const':
/usr/include/boost/log/attributes/attribute_set.hpp:121: undefined reference to `boost::log_mt_posix::basic_slim_string<char, std::char_traits<char> >::basic_slim_string(char const*, unsigned long)'
/usr/include/boost/log/attributes/attribute_set.hpp:121: undefined reference to `boost::log_mt_posix::basic_attribute_set<char>::insert(boost::log_mt_posix::basic_slim_string<char, std::char_traits<char> > const&, boost::shared_ptr<boost::log_mt_posix::attribute> const&)'
/usr/include/boost/log/attributes/attribute_set.hpp:121: undefined reference to `boost::log_mt_posix::basic_slim_string<char, std::char_traits<char> >::~basic_slim_string()'
/usr/include/boost/log/attributes/attribute_set.hpp:121: undefined reference to `boost::log_mt_posix::basic_slim_string<char, std::char_traits<char> >::~basic_slim_string()'
./main.o: In function `pair<std::basic_string<char>, boost::shared_ptr<boost::log_mt_posix::attribute> >':
/usr/include/c++/4.5/bits/stl_pair.h:116: undefined reference to `boost::log_mt_posix::basic_slim_string<char, std::char_traits<char> >::basic_slim_string(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
./main.o: In function `boost::log_mt_posix::basic_attribute_set<char>::insert(std::pair<boost::log_mt_posix::basic_slim_string<char, std::char_traits<char> > const, boost::shared_ptr<boost::log_mt_posix::attribute> > const&)':
/usr/include/boost/log/attributes/attribute_set.hpp:507: undefined reference to `boost::log_mt_posix::basic_attribute_set<char>::insert(boost::log_mt_posix::basic_slim_string<char, std::char_traits<char> > const&, boost::shared_ptr<boost::log_mt_posix::attribute> const&)'
./main.o: In function `boost::log_mt_posix::sources::aux::severity_level<boost::log_mt_posix::trivial::severity_level>::dispatch(boost::log_mt_posix::type_dispatcher&)':
/usr/include/boost/log/sources/severity_feature.hpp:105: undefined reference to `boost::log_mt_posix::sources::aux::get_severity_level()'
./main.o: In function `boost::log_mt_posix::sources::aux::severity_level<boost::log_mt_posix::trivial::severity_level>::detach_from_thread()':
/usr/include/boost/log/sources/severity_feature.hpp:118: undefined reference to `boost::log_mt_posix::sources::aux::get_severity_level()'
collect2: ld returned 1 exit status
make: *** [LoggingCpp] Error 1
About Boost Log syntax
Did I install Boost Log incorrectly? Am I missing crucial libraries? Did I omit necessary linker flags?
You need to add something like -lboost-log-mt to your link line.
It looks like you haven't built log?
Once you've copied the log header files, etc into the corresponding folders in your boost distro (keep the same structure i.e. merge the headers to the headers, the libs folder into the libs folder of your boost distro, etc), you still need to build boost and then like John mentioned, link against it. That's why the link you referred to above points you to the standard boost build instructions.
It's a while ago, but AFAIR on linux you simply run ./bjam in the root of your boost folder.
Maybe switch unright version of the boost_log.
I have the same issue for undefined reference to "boost::log::v2_mt_posix::core::push_record_move(boost::log::v2_mt_posix::record&)"
I build the libboost_log by myself. And I use the nm to grep the push_record_move found that, "boost::log::v2s_mt_posix::core::push_record_move(boost::log::v2s_mt_posix::record&)"
From the experience of before, should add some cflag in the Makefile.