zeni has asked for the wisdom of the Perl Monks concerning the following question:

Hi All,

I have used swig as interface btw perl and c++ world. There are 2 c++ functions which are invoked from the interface file. I then create a .o and .so files and finally run the perl file.

VIP2vera_interface is the interface class in which c++ functions are declared and the header file is below:
class VIP2vera_interface { public: VIP2vera_interface(); ~VIP2vera_interface(); void _getUserInfo ( char *userInfo ); void _fileDirCheckAndParserCall (char *userInfo); };

_getUserInfo , _fileDirCheckAndParserCall are used to call the 2 c++ functions respectively.

I then do

1. g++ -m32 -lfl -shared AHB_Class.o vip2vera_interface_wrap.o -o vip2vera_interface.so -ldl $EXPAT_LIB

vip2vera_interface.so is created.

2. perl vip2vera_interface.pl

error:

perl: relocation error: ./vip2vera_interface.so: undefined symbol: _ZN18VIP2vera_interfaceC1Ev

AHB_Class is where the 2 functions are defined. where am i going wrong? Please help!

zen

Replies are listed 'Best First'.
Re: Relocation error
by cdarke (Prior) on Feb 15, 2010 at 09:36 UTC
    On the assumption that you do not have a function called _ZN18VIP2vera_interfaceC1Ev, the C1Ev suffix looks like name mangling (its the way that C++ fakes function overloading). My guess is that you are using a compiler with a different name mangling scheme than the one that perl is expecting. Check the compiler versions.
Re: Relocation error
by Anonymous Monk on Feb 15, 2010 at 05:06 UTC
    1) :D you're doing it wrong :) 2) use Inline::CPP, let Inline::CPP generate glue for you, then

      Hi Monk, i have tried a similar approach earlier and it is just working fine! How will it differ if the function is defined elsewhere?