I write a C++ program to invoke a function coded with python and everything goes well, the program has been successfully compiled. However, when I use this program, it posts the error like this:
gzserver: symbol lookup error: /home/shin/gazebo_plugin_tutorial/build/libhello_world.so: undefined symbol: Py_Initialize
I used to guess it is because I do not link related library and I try to modify the CMake file, but there is no effect. I have searched for a long time, but similar cases always happen in the stage of compiling, those solution seems do not work in my case, and I really do not know how to deal with this case.
Here is my simple C++ code:
public: void OnNewFrame(const unsigned char *_image,
unsigned int _width, unsigned int _height, unsigned int _depth,
const std::string &_format)
{
const unsigned char * str = this->parentSensor->GetCamera()->ImageData();
const char* str1 = static_cast<const char*>( static_cast<void*>( const_cast<unsigned char*>(str)));
Py_Initialize();
PyObject *pyMod = PyImport_ImportModule("/home/shin/gazebo_plugin_tutorial/int");
PyObject *pyFunc = PyObject_GetAttrString(pyMod,"reimg");
PyObject *pyParams = PyTuple_New(1);
PyTuple_SetItem(pyParams,0,PyString_FromString(str1));
PyObject_CallObject(pyFunc,pyParams);
}
Could someone give me a hand?