shared libraries - How to do manual wrapping of C++ code into Python in Ubuntu -


below code calling c++ api's python:

#include <python.h>  #include "dijsdk.h"  #include <iostream>  #include <qstring>  #include "arraysize.h"  static pyobject* sdktest_getversion(pyobject* self,pyobject* args);  static pymethoddef defmethod[]={ {"dijsdk_getversion", sdktest_getversion, meth_varargs, "dijsdk_getversion() -> string. retrieves sdk version number."}, {null,null,0,null} };  pymodinit_func  initsdktest(void) { (void) py_initmodule("sdktest", defmethod); }  static pyobject* sdktest_getversion(pyobject* self,pyobject* args) { const char* name;  if (!pyarg_parsetuple(args, "s", &name)) return null;  printf("hello %s!\n", name);  error_t result = e_ok; qstring m_guids[16]; dijsdk_camguid guids[arraysize(m_guids)] = {0}; unsigned int numguids = arraysize(guids); char version[256] = {0}; unsigned int maxlength = arraysize(version); result = dijsdk_getversion(version, maxlength); std::cout<<"version = "<<version<<"\n"; result = dijsdk_init(); //api call result = dijsdk_findcameras(guids, &numguids); //api call std::cout<<"\nnumguids = " <<numguids; std::cout<<"\nresult = "<<result; py_return_none; } 

i compiling file using following command:

  $g++ -fpic -g -c -wall -i/usr/include/python2.7 -i/usr/include/qt4/qtcore -i/usr/include/qt4/qtcore -i/usr/include/qt4/qtgui -i/usr/include/qt4/qtgui -i/usr/include/qt4 -i. -i. sdktest.cpp 

i creating .so file using command:

  $ g++ -shared -rdynamic -o sdktest.so sdktest.o -l/usr/lib/i386-linux-gnu/ -lpython2.7 -ldijsdk -lqtgui -lqtcore -wl,-rpath=/home/embadmin/desktop/linux/dijsdk-1.1.7-linux/bin/ 

and once .so file created placing file in : /usr/lib/python2.7/dist-packages , importing module "sdktest" python interpreter.

here going fine without errors.

my concern here is: during runtime c++ library dijsdk.so file load library should placed .so file loading python. have placed runtime libraries in folder .so file placed still not getting loaded.

i have tried same scenario pure c++ code , libraries getting called , whats special python here? doing wrong here?

and same code working fine in windows, there creating pyd file using visual studio.

is there settings have in linux work correctly?


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -