Compile problem

436 views
Skip to first unread message

Jakub Nykiel

unread,
Oct 17, 2017, 8:57:09 AM10/17/17
to MQTT
Hi

I'm having problem with compile sample program.

pi@zero:~/paho.mqtt.cpp/src/samples $ g++ async_publish.cpp -o test
/tmp/ccRraZrG.o: In function `main':
async_publish.cpp:(.text+0x424): undefined reference to `mqtt::async_client::async_client(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&, mqtt::iclient_persistence*)'
async_publish.cpp:(.text+0x444): undefined reference to `mqtt::async_client::set_callback(mqtt::callback&)'
async_publish.cpp:(.text+0x450): undefined reference to `mqtt::connect_options::connect_options()'
async_publish.cpp:(.text+0x49c): undefined reference to `mqtt::message::message(mqtt::buffer_ref<char>, mqtt::buffer_ref<char>, int, bool)'
async_publish.cpp:(.text+0x4d8): undefined reference to `mqtt::will_options::will_options(mqtt::message const&)'
async_publish.cpp:(.text+0x4f4): undefined reference to `mqtt::connect_options::set_will(mqtt::will_options const&)'
async_publish.cpp:(.text+0x540): undefined reference to `mqtt::connect_options::connect_options(mqtt::connect_options const&)'
async_publish.cpp:(.text+0x558): undefined reference to `mqtt::async_client::connect(mqtt::connect_options)'
async_publish.cpp:(.text+0x690): undefined reference to `mqtt::async_client::publish(std::shared_ptr<mqtt::message const>)'
async_publish.cpp:(.text+0x760): undefined reference to `mqtt::async_client::publish(mqtt::buffer_ref<char>, void const*, unsigned int, int, bool)'
async_publish.cpp:(.text+0x9b0): undefined reference to `mqtt::async_client::publish(std::shared_ptr<mqtt::message const>, void*, mqtt::iaction_listener&)'
async_publish.cpp:(.text+0xb14): undefined reference to `mqtt::async_client::publish(std::shared_ptr<mqtt::message const>, void*, mqtt::iaction_listener&)'
async_publish.cpp:(.text+0xbb8): undefined reference to `mqtt::async_client::get_pending_delivery_tokens() const'
async_publish.cpp:(.text+0xd54): undefined reference to `mqtt::async_client::~async_client()'
async_publish.cpp:(.text+0x1090): undefined reference to `mqtt::async_client::~async_client()'
/tmp/ccRraZrG.o: In function `mqtt::message::create(mqtt::buffer_ref<char>, mqtt::buffer_ref<char>)':
async_publish.cpp:(.text._ZN4mqtt7message6createENS_10buffer_refIcEES2_[_ZN4mqtt7message6createENS_10buffer_refIcEES2_]+0x54): undefined reference to `mqtt::message::DFLT_RETAINED'
async_publish.cpp:(.text._ZN4mqtt7message6createENS_10buffer_refIcEES2_[_ZN4mqtt7message6createENS_10buffer_refIcEES2_]+0x58): undefined reference to `mqtt::message::DFLT_QOS'
/tmp/ccRraZrG.o: In function `mqtt::message::get_payload[abi:cxx11]() const':
async_publish.cpp:(.text._ZNK4mqtt7message11get_payloadB5cxx11Ev[_ZNK4mqtt7message11get_payloadB5cxx11Ev]+0x54): undefined reference to `mqtt::message::EMPTY_BIN[abi:cxx11]'
/tmp/ccRraZrG.o: In function `mqtt::async_client::disconnect()':
async_publish.cpp:(.text._ZN4mqtt12async_client10disconnectEv[_ZN4mqtt12async_client10disconnectEv]+0x2c): undefined reference to `mqtt::disconnect_options::disconnect_options()'
/tmp/ccRraZrG.o: In function `void __gnu_cxx::new_allocator<mqtt::message>::construct<mqtt::message, mqtt::buffer_ref<char>, mqtt::buffer_ref<char>, int const&, bool const&>(mqtt::message*, mqtt::buffer_ref<char>&&, mqtt::buffer_ref<char>&&, int const&, bool const&)':
async_publish.cpp:(.text._ZN9__gnu_cxx13new_allocatorIN4mqtt7messageEE9constructIS2_JNS1_10buffer_refIcEES6_RKiRKbEEEvPT_DpOT0_[_ZN9__gnu_cxx13new_allocatorIN4mqtt7messageEE9constructIS2_JNS1_10buffer_refIcEES6_RKiRKbEEEvPT_DpOT0_]+0xac): undefined reference to `mqtt::message::message(mqtt::buffer_ref<char>, mqtt::buffer_ref<char>, int, bool)'
collect2: error: ld returned 1 exit status

Frank Pagliughi

unread,
Oct 17, 2017, 1:48:13 PM10/17/17
to mq...@googlegroups.com, Jakub Nykiel
You need to link to both the Paho C++ and C libraries. Look at the Makefile(s) or CMake files to see how to do that.

Frank
--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+uns...@googlegroups.com.
To post to this group, send email to mq...@googlegroups.com.
Visit this group at https://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted
Message has been deleted

Sarah

unread,
Apr 27, 2023, 1:09:27 PM4/27/23
to MQTT
Hello Ms.Frank

i have the same error above, can you please explain to me how to link to both the Paho C++ and C libraries.

Can anyone  please  help with this ?
Sarah
Reply all
Reply to author
Forward
0 new messages