You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/11/11 10:41:15 UTC

[GitHub] [pulsar] frkn4129 opened a new issue #12751: pulsar-client-cpp error!

frkn4129 opened a new issue #12751:
URL: https://github.com/apache/pulsar/issues/12751


   
   
   
   
   
   **I am getting an error like this, does anyone know the solution?**
   
   
   /usr/bin/ld: /tmp/cc6Xvjf3.o: in function `main':
   deneme.cpp:(.text+0x54): undefined reference to `pulsar::Client::Client(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
   /usr/bin/ld: deneme.cpp:(.text+0x78): undefined reference to `pulsar::Consumer::Consumer()'
   /usr/bin/ld: deneme.cpp:(.text+0x87): undefined reference to `pulsar::ConsumerConfiguration::ConsumerConfiguration()'
   /usr/bin/ld: deneme.cpp:(.text+0x9b): undefined reference to `pulsar::ConsumerConfiguration::setSubscriptionInitialPosition(pulsar::InitialPosition)'
   /usr/bin/ld: deneme.cpp:(.text+0x112): undefined reference to `pulsar::Client::subscribe(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&, pulsar::ConsumerConfiguration const&, pulsar::Consumer&)'
   /usr/bin/ld: deneme.cpp:(.text+0x17d): undefined reference to `pulsar::operator<<(std::ostream&, pulsar::Result)'
   /usr/bin/ld: deneme.cpp:(.text+0x1ab): undefined reference to `pulsar::Message::Message()'
   /usr/bin/ld: deneme.cpp:(.text+0x1d8): undefined reference to `pulsar::Consumer::receive(pulsar::Message&)'
   /usr/bin/ld: deneme.cpp:(.text+0x200): undefined reference to `pulsar::operator<<(std::ostream&, pulsar::Message const&)'
   /usr/bin/ld: deneme.cpp:(.text+0x228): undefined reference to `pulsar::Message::getDataAsString[abi:cxx11]() const'
   /usr/bin/ld: deneme.cpp:(.text+0x27d): undefined reference to `pulsar::Consumer::acknowledge(pulsar::Message const&)'
   /usr/bin/ld: deneme.cpp:(.text+0x2c0): undefined reference to `pulsar::Client::close()'
   /usr/bin/ld: deneme.cpp:(.text+0x2e3): undefined reference to `pulsar::ConsumerConfiguration::~ConsumerConfiguration()'
   /usr/bin/ld: deneme.cpp:(.text+0x3df): undefined reference to `pulsar::ConsumerConfiguration::~ConsumerConfiguration()'
   /usr/bin/ld: /tmp/cc6Xvjf3.o: in function `pulsar::Consumer::~Consumer()':
   deneme.cpp:(.text._ZN6pulsar8ConsumerD2Ev[_ZN6pulsar8ConsumerD5Ev]+0x13): undefined reference to `vtable for pulsar::Consumer'
   collect2: error: ld returned 1 exit status
   
   
   
   
   **my code** 
   
   
   #include <pulsar/Client.h>
   
   using namespace pulsar;
   
   int main() {
       Client client("pulsar://localhost:6650");
   
       Consumer consumer;
       ConsumerConfiguration config;
       config.setSubscriptionInitialPosition(InitialPositionEarliest);
       Result result = client.subscribe("persistent://public/default/my-topic", "consumer-1", config, consumer);
       if (result != ResultOk) {
           std::cout << "Failed to subscribe: " << result << std::endl;
           return -1;
       }
   
       Message msg;
       int ctr = 0;
       // consume 100 messages
       while (ctr < 100) {
           consumer.receive(msg);
           std::cout << "Received: " << msg
               << "  with payload '" << msg.getDataAsString() << "'" << std::endl;
   
           consumer.acknowledge(msg);
           ctr++;
       }
   
       std::cout << "Finished consuming synchronously!" << std::endl;
   
       client.close();
       return 0;
   }


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] BewareMyPower commented on issue #12751: pulsar-client-cpp error!

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on issue #12751:
URL: https://github.com/apache/pulsar/issues/12751#issuecomment-966752127


   It looks like that your application doesn't link to the pulsar library correctly.  Could you give more details about how did you build the pulsar cpp library? Or just use the library from the pre-built binary? You can also use `ldd` to see whether your application links to the pulsar cpp library.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] github-actions[bot] commented on issue #12751: pulsar-client-cpp error!

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on issue #12751:
URL: https://github.com/apache/pulsar/issues/12751#issuecomment-1052937339


   The issue had no activity for 30 days, mark with Stale label.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] codelipenghui commented on issue #12751: pulsar-client-cpp error!

Posted by GitBox <gi...@apache.org>.
codelipenghui commented on issue #12751:
URL: https://github.com/apache/pulsar/issues/12751#issuecomment-966369781


   @frkn4129 Could you please provide more context such as which Pulsar CPP client version?
   cc @BewareMyPower Please help take a look at this issue.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org