'eprosima FastDDS symbol lookup error for new function in DomainParticipant
I tried to implement a new function in the eprosimas FastDDS DomainParticipant class which causes a symbol lookup error. My executable is called "Vector". It shall send a vector via DDS/RTPS. The program runs perfectly, if I don't call my new function in the DomainParticipant class
The application:
./Vector publisher
causes:
./Vector: symbol lookup error: ./Vector: undefined symbol: _ZN8eprosima7fastdds3dds17DomainParticipant11return_testB5cxx11Ev.
I broke down the problem to a simple function, so I hope you can understand. I added the following function to the DomainParticipant cpp (and hpp):
std::string DomainParticipant::return_test()
{
return std::string("Test\n\r");
}
The function call is inside the initialization of the publisher. The parameters for the initialization are given by a xml file. My application follows the examples of eprosimas FastDDS. Most is copy&paste from other examples. If you are familiar with these, you might recognize the code snippet
bool VectorPublisher::init()
{
// Load xml file
if (ReturnCode_t::RETCODE_OK ==
DomainParticipantFactory::get_instance()->load_XML_profiles_file("DEFAULT_FASTRTPS_PROFILES.xml"))
{
participant_ = DomainParticipantFactory::get_instance()->create_participant_with_profile(0, "participant_profile");
if (participant_ == nullptr)
{
return false;
}
//REGISTER THE TYPE
type_.register_type(participant_);
//CREATE THE PUBLISHER
publisher_ = participant_->create_publisher(PUBLISHER_QOS_DEFAULT, nullptr);
if (publisher_ == nullptr)
{
return false;
}
topic_ = participant_->create_topic("VectorTopic", "Vector", TOPIC_QOS_DEFAULT);
if (topic_ == nullptr)
{
return false;
}
// CREATE THE WRITER
writer_ = publisher_->create_datawriter_with_profile(topic_, "datawriter_profile", &listener_);
if (writer_ == nullptr)
{
return false;
}
std::string test = "this";
// This line causes the symbol lookup error:
test = participant_->return_test();
std::cout << test << std::endl;
}
else
{
logError(VECTORPUBLISHER, "Initialization of publisher failed. Problem loading xml.");
return false;
}
return true;
}
The function call of return_test() causes the error:
test = participant_->return_test();
If I comment the line, everything works fine.
I am have basic C++ skills and I have a hard time trying to understand the problem. If anyone has a hint why I get a symbol lookup error, I would appreciate it. If there are further question about my code, I can add some information. Thanks in advance.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
