1

i have the following code:

  #include "Poco/Net/DatagramSocket.h"
    #include "Poco/Net/SocketAddress.h"
    #include "Poco/Timestamp.h"
    #include "Poco/DateTimeFormatter.h"

    int main(int argc, char** argv)
    {

    Poco::Net::SocketAddress sa("127.0.0.1", 8080);

    Poco::Net::DatagramSocket dgs(sa);
    std::string syslogMsg;
    Poco::Timestamp now;
    syslogMsg = Poco::DateTimeFormatter::format(now,
    "<14>%w %f %H:%M:%S Hello, world!");

    return 0;

}

and after compiling i get the following errors:

/tmp/cc38RdWw.o: In function `main':
pocoSender.cpp:(.text+0x4d): undefined reference to `Poco::Net::SocketAddress::SocketAddress(std::string const&, unsigned short)'
pocoSender.cpp:(.text+0x7d): undefined reference to `Poco::Net::DatagramSocket::DatagramSocket(Poco::Net::SocketAddress const&, bool)'
pocoSender.cpp:(.text+0x93): undefined reference to `Poco::Timestamp::Timestamp()'
pocoSender.cpp:(.text+0x11f): undefined reference to `Poco::Timestamp::~Timestamp()'
pocoSender.cpp:(.text+0x135): undefined reference to `Poco::Net::DatagramSocket::~DatagramSocket()'
pocoSender.cpp:(.text+0x140): undefined reference to `Poco::Net::SocketAddress::~SocketAddress()'
pocoSender.cpp:(.text+0x163): undefined reference to `Poco::Net::SocketAddress::~SocketAddress()'
pocoSender.cpp:(.text+0x1ac): undefined reference to `Poco::Timestamp::~Timestamp()'
pocoSender.cpp:(.text+0x1ca): undefined reference to `Poco::Net::DatagramSocket::~DatagramSocket()'
pocoSender.cpp:(.text+0x1d9): undefined reference to `Poco::Net::SocketAddress::~SocketAddress()'
/tmp/cc38RdWw.o: In function `Poco::DateTimeFormatter::format(Poco::Timestamp const&, std::string const&, int)':
pocoSender.cpp:(.text._ZN4Poco17DateTimeFormatter6formatERKNS_9TimestampERKSsi[_ZN4Poco17DateTimeFormatter6formatERKNS_9TimestampERKSsi]+0x15): undefined reference to `Poco::DateTime::DateTime(Poco::Timestamp const&)'
pocoSender.cpp:(.text._ZN4Poco17DateTimeFormatter6formatERKNS_9TimestampERKSsi[_ZN4Poco17DateTimeFormatter6formatERKNS_9TimestampERKSsi]+0x43): undefined reference to `Poco::DateTime::~DateTime()'
pocoSender.cpp:(.text._ZN4Poco17DateTimeFormatter6formatERKNS_9TimestampERKSsi[_ZN4Poco17DateTimeFormatter6formatERKNS_9TimestampERKSsi]+0x52): undefined reference to `Poco::DateTime::~DateTime()'
/tmp/cc38RdWw.o: In function `Poco::DateTimeFormatter::format(Poco::DateTime const&, std::string const&, int)':
pocoSender.cpp:(.text._ZN4Poco17DateTimeFormatter6formatERKNS_8DateTimeERKSsi[_ZN4Poco17DateTimeFormatter6formatERKNS_8DateTimeERKSsi]+0x41): undefined reference to `Poco::DateTimeFormatter::append(std::string&, Poco::DateTime const&, std::string const&, int)'
collect2: error: ld returned 1 exit status

i use the following commandline to compile:

g++ -L/usr/local/lib -lPocoUtil -lPocoFoundation -lPocoNet pocoSender.cpp -o hello

please do not mark the question as duplicate as i have included the required libraries using g++ flags, but i am still getting these errors.

Mgetz
  • 5,108
  • 2
  • 33
  • 51
fer y
  • 505
  • 4
  • 19
  • 2
    Libraries go AFTER source and object files on the command line. – n. m. could be an AI Jan 08 '14 at 17:06
  • Maybe `-L/usr/local/lib` refers a place where the libs aren't present. Also suspicious how you're going to specify `pocoSender.cpp` on your linker command, it should appear **before** the library specs ... – πάντα ῥεῖ Jan 08 '14 at 17:07
  • 1
    possible duplicate of [g++ linking order dependency when linking c code to c++ code](http://stackoverflow.com/questions/3363398/g-linking-order-dependency-when-linking-c-code-to-c-code) – n. m. could be an AI Jan 08 '14 at 17:11

1 Answers1

0

It means that the compiler or linker did not find implementations of these functions. It seems that the corresponding libraries or object modules were not included in building of the project.

Vlad from Moscow
  • 301,070
  • 26
  • 186
  • 335