Requester connext rti

3 posts / 0 new
Last post
Offline
Last seen: 7 years 8 months ago
Joined: 04/07/2016
Posts: 8
Requester connext rti

Hi

when i am trying to create object of Requester class in c++ on linux i got multiple problems which are defined below

1. undefined reference to `DDS_Duration_t::operator-(DDS_Duration_t const&) const'

2.undefined reference to `DDS_Duration_t::operator==(DDS_Duration_t const&) const'

 

Requester<Foo, Bar> * requester;
requester = new Requester<Foo, Bar>(participant, "TestService");

 

The complete program is as follows

 

#include "ndds/ndds_requestreply_cpp.h"
#include <iostream>
#include "idl/Primes.h"
#include "idl/PrimesSupport.h"
#include "idl/PrimesPlugin.h"
#include "ndds/ndds_namespace_cpp.h"
using namespace connext;

int main()
{
DDS::WaitSet ws;
int domain_id = 1;

// Create a DomainParticipant

DDS::DomainParticipant * participant =
DDS::DomainParticipantFactory::get_instance()->create_participant(
domain_id, DDS::PARTICIPANT_QOS_DEFAULT,
NULL, DDS::STATUS_MASK_NONE);

if (participant == NULL)
{
std::cout<<"participant not created"<<std::endl;
}
else
{
std::cout<<"participant created"<<std::endl;

// Create a Requester

Requester<Foo, Bar> * requester;
requester = new Requester<Foo, Bar>(participant, "TestService");

// Send request

WriteSample<Foo> request;
strcpy(request.data().message, "A Request");
std::cout<<"data:: "<<request.data().message<<std::endl;
requester->send_request(request);
// Create a reply Sample
Sample<Bar> reply;

// Receive reply (wait for it and get the sample)

DDS_Duration_t MAX_WAIT;
MAX_WAIT.sec = 10;

bool received = requester->receive_reply(reply, MAX_WAIT);
if (received)
{
if(reply.info().valid_data)
{
std::cout << "Received reply: " << reply.data().message << std::endl;
}
else
{
std::cout << "Received invalid reply" << std::endl;
}
}
else
{
std::cout << "Reply not received" << std::endl;
}
}
}

Thanks

Bhawna Popli

Organization:
Gerardo Pardo's picture
Offline
Last seen: 17 hours 24 min ago
Joined: 06/02/2010
Posts: 601

I take you are getting link-time errors for "unresolved symbols" than compile-time errors, correct?

Your source code compiles fine for me. I just tried compiling it and it compiled and linked without errors. So I think the problem may be the way your makefile is setting up the environment or the libraries that it links. Are you linking in both the rticonnextmsgcpp and rticonnextmsgc? Those two libraries are required to get in the request-reply symbols.

For example this is the link line I used when linking statically on Linux

 
g++ -m32 -static-libgcc -Wl,--no-as-needed  \
    -o objs/i86Linux3gcc4.8.2/NewType_publisher objs/i86Linux3gcc4.8.2/NewType_publisher.o \
    objs/i86Linux3gcc4.8.2/NewTypeSupport.o objs/i86Linux3gcc4.8.2/NewTypePlugin.o objs/i86Linux3gcc4.8.2/NewType.o \
    -L/home/gerardo/rti_connext_dds-5.2.0/lib/i86Linux3gcc4.8.2 \
    -lrticonnextmsgcppz -lrticonnextmsgcz -lnddscppz -lnddscz -lnddscorez -ldl -lnsl -lm -lpthread -lrt

You can find the list of the required libraries in the Platform Notes. For example Table 5.4 specifies the libraries here: https://community.rti.com/static/documentation/connext-dds/5.2.0/doc/manuals/connext_dds/RTI_ConnextDDS_CoreLibraries_PlatformNotes.html If this does not address your problem you may want to post here the full compile or link line that is resulting on the error as well as the exact error message so that we can see how you are building.

Gerardo

Offline
Last seen: 7 years 8 months ago
Joined: 04/07/2016
Posts: 8

Yes, There was some linking errors in the code which was resolved

Thanks

Bhawna Popli