PBS with SWIG tool

I am working on generating python wrappers using SWIG tool. When I try to run the code, I am getting error -

Traceback (most recent call last):
File “pbs_statnode.py”, line 1, in
from pbs import pbs_connect, pbs_stathost, pbs_statvnode
File “/xxxxx/pbs.py”, line 26, in
_pbs = swig_import_helper()
File “/xxxxx/pbs.py”, line 22, in swig_import_helper
_mod = imp.load_module(’_pbs’, fp, pathname, description)
ImportError: /xxxxx/_pbs.so: undefined symbol: pbs_geterrmsg

Both - pbs.py and pbs.so files are autogenerated files after using the swig tool.

Is anyone working on SWIG? Need help!

A couple things you may want to check…

  • Make sure your LD_LIBRARY_PATH includes the path to libpbs.so
  • Check the output of the following:

$ nm -D /opt/pbs/lib/libpbs.so | grep pbs_geterrmsg
000000000002fcd0 T __pbs_geterrmsg
00000000000379d0 T pbs_geterrmsg

Can you please share exactly how you are getting to this step? This works for me:

[root@centos7-2 swig]# cat pbs.i
/* File : pbs.i */
%module pbs
%{
#define   SWIG_FILE_WITH_INIT
#include "pbs_ifl.h"
%}
%include "pbs_ifl.h"


[root@centos7-2 swig]# . /etc/pbs.conf
[root@centos7-2 swig]# swig -I$PBS_EXEC/include -python pbs.i
[root@centos7-2 swig]# gcc -shared -fPIC -I /usr/include/python2.7 -I $PBS_EXEC/include pbs_wrap.c -lpbs -o _pbs.so
[root@centos7-2 swig]# cat t.py
import pbs

[root@centos7-2 swig]# LD_LIBRARY_PATH=$PBS_EXEC/lib python ./t.py
[root@centos7-2 swig]# echo $?
0
[root@centos7-2 swig]#

@tejal Also you may want to look at Pbs_ifl access from python