I’m trying to use a .so plugin which I compiled using Linux but i keep getting EntryPointNotFoundException
Here’s a sample of the c++ code.
cpp:
#include <rosgraph_msgs/Clock.h>
#include <unistd.h>
#include <thread>
#include "ros_interface.hpp"
#include "node.hpp"
// Default initializer
ros_interface::ros_interface() {
// NOP
}
// Initialize the ROS communication interface
ros_interface::ros_interface(int argc, char** argv, string node_name) {
// ROS initialization
ros::init(argc,argv,node_name);
// Set the time simulation as in "/clock"
system("rosparam set /use_sim_time true");
// Initialize the pointer to clocker
c = new clocker;
// Set publisher on clocker
c->pub_clock = c->nh.advertise<rosgraph_msgs::Clock>("/clock",1);
}
// Destructor
ros_interface::~ros_interface() {
// Delete all node pointers in nodes_ptr
for(auto x : nodes_ptr) delete *((node**) x);
// Delete clock struct pointer
delete(c);
}
extern "C" void initialize() {
instance = new ros_interface(0, 0, "instance");
}
// Lots of other stuff
And the hpp:
#ifndef ROS_INTERFACE_H
#define ROS_INTERFACE_H
#include <string>
#include <vector>
// Position data type
struct position {
double x; // position in x
double y; // position in y
double z; // position in z
double roll; // lateral axis (X)
double pitch; // longitudinal axis (Y)
double yaw; // vertical axis (Z)
};
// Velocity data type
struct velocity {
double x; // velocity in x
double y; // velocity in y
double z; // velocity in z
double roll; // lateral axis angular velocity
double pitch; // longitudinal axis angular velocity
double yaw; // vertical axis angular velocity
};
extern "C" void initialize();
extern "C" void addNode(int id, int type, std::string target, position init_pose);
extern "C" void setVelocity(int id, velocity msg);
extern "C" position getPos(int id);
extern "C" void setClock(float dt);
extern "C" bool rosOk();
// Node class to ROS interface
class ros_interface {
public:
// Default initializer
ros_interface();
// Initialize the ROS communication interface
ros_interface(int argc, char** argv, std::string node_name);
// Destructor
~ros_interface();
// And more stuff...
And here’s the c# code used in unity:
[DllImport("ros_interface")]
private static extern void initialize();
[DllImport("ros_interface")]
private static extern void addNode(int id, int type, string target, Pose init_pose);
[DllImport("ros_interface")]
private static extern void setVelocity(int id, Pose p);
[DllImport("ros_interface")]
private static extern bool rosOk();
// Use this for initialization
void Start()
{
initialize();
}
I build it sucessfully with unity and then run it on linux, but i get the following error when calling the initialize method:
EntryPointNotFoundException: initialize
I did some research, this error means that the initialize method was not found on the plugin, but the method seems to be there and I haven’t found a solution. The same error will pop if I try to call any of the methods from the .so plugin.
What can I do to make this plugin work?