Uploaded image for project: 'Qpid'
  1. Qpid
  2. QPID-7814

Can't Compile "Hello World" example with g++, but can compile with clang++

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Bug
    • qpid-cpp-1.36.0
    • None
    • C++ Client
    • Ubuntu 16.04 Docker Image

    Description

      The example hello_world.cpp program does not compile when using g++ in my Ubuntu 16.04 Docker image, but does when using clang+. I attempted to compile it with g+ 5.4.0, g++ 4.9 and g++ 4.8 but I get the same error for each. The command entered was "g++ -lqpidtypes -lqpidmessaging helloWorld.cpp". When using clang++ 3.8.0 with the command "clang++ -lqpidtypes -lqpidmessaging helloWorld.cpp" the code compiles.

      I am pretty sure that it is able to find the libraries because when I do something like "g++ -lqpidtypes -lqpidmessagin helloWorld.cpp" (note the missing g on messaging) it says "/usr/bin/ld: cannot find -lqpidmessagin". When the libraries are typed correctly I get the following:

      /tmp/ccNPg3lI.o: In function `main':
      helloWorld.cpp.text+0xba): undefined reference to `qpid::messaging::Connection::Connection(std::string const&, std::string const&)'
      helloWorld.cpp.text+0xc9): undefined reference to `qpid::messaging::Connection::open()'
      helloWorld.cpp.text+0xf8): undefined reference to `qpid::messaging::Connection::createSession(std::string const&)'
      helloWorld.cpp.text+0x127): undefined reference to `qpid::messaging::Session::createReceiver(std::string const&)'
      helloWorld.cpp.text+0x144): undefined reference to `qpid::messaging::Session::createSender(std::string const&)'
      helloWorld.cpp.text+0x163): undefined reference to `qpid::messaging::Message::Message(std::string const&)'
      helloWorld.cpp.text+0x180): undefined reference to `qpid::types::Variant::Variant(char const*)'
      helloWorld.cpp.text+0x193): undefined reference to `qpid::messaging::Message::setContentObject(qpid::types::Variant const&)'
      helloWorld.cpp.text+0x19f): undefined reference to `qpid::types::Variant::~Variant()'
      helloWorld.cpp.text+0x1cc): undefined reference to `qpid::messaging::Message::getContentObject()'
      helloWorld.cpp.text+0x1db): undefined reference to `qpid::types::Variant::setEncoding(std::string const&)'
      helloWorld.cpp.text+0x20b): undefined reference to `qpid::messaging::Sender::send(qpid::messaging::Message const&, bool)'
      helloWorld.cpp.text+0x215): undefined reference to `qpid::messaging::Duration::SECOND'
      helloWorld.cpp.text+0x21a): undefined reference to `qpid::messaging::operator*(qpid::messaging::Duration const&, unsigned long)'
      helloWorld.cpp.text+0x233): undefined reference to `qpid::messaging::Receiver::fetch(qpid::messaging::Duration)'
      helloWorld.cpp.text+0x246): undefined reference to `qpid::messaging::Message::operator=(qpid::messaging::Message const&)'
      helloWorld.cpp.text+0x252): undefined reference to `qpid::messaging::Message::~Message()'
      helloWorld.cpp.text+0x265): undefined reference to `qpid::messaging::Message::getContent() const'
      helloWorld.cpp.text+0x2a3): undefined reference to `qpid::messaging::Session::acknowledge(bool)'
      helloWorld.cpp.text+0x2b2): undefined reference to `qpid::messaging::Connection::close()'
      helloWorld.cpp.text+0x2c3): undefined reference to `qpid::messaging::Message::~Message()'
      helloWorld.cpp.text+0x2cf): undefined reference to `qpid::messaging::Sender::~Sender()'
      helloWorld.cpp.text+0x2de): undefined reference to `qpid::messaging::Receiver::~Receiver()'
      helloWorld.cpp.text+0x2ed): undefined reference to `qpid::messaging::Session::~Session()'
      helloWorld.cpp.text+0x2fc): undefined reference to `qpid::messaging::Connection::~Connection()'
      helloWorld.cpp.text+0x3a1): undefined reference to `qpid::messaging::Session::~Session()'
      helloWorld.cpp.text+0x3cf): undefined reference to `qpid::messaging::Message::~Message()'
      helloWorld.cpp.text+0x3e3): undefined reference to `qpid::types::Variant::~Variant()'
      helloWorld.cpp.text+0x41f): undefined reference to `qpid::messaging::Message::~Message()'
      helloWorld.cpp.text+0x447): undefined reference to `qpid::messaging::Message::~Message()'
      helloWorld.cpp.text+0x45b): undefined reference to `qpid::messaging::Sender::~Sender()'
      helloWorld.cpp.text+0x472): undefined reference to `qpid::messaging::Receiver::~Receiver()'
      helloWorld.cpp.text+0x489): undefined reference to `qpid::messaging::Session::~Session()'
      helloWorld.cpp.text+0x4a0): undefined reference to `qpid::messaging::Connection::~Connection()'
      collect2: error: ld returned 1 exit status

      Note that I was able to compile the same code using g++ 4.8.5 on CentOS 7 and it runs as expected.

      Attachments

        Activity

          People

            jross Justin Ross
            msingman Matt Singman
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: