in reply to Re^3: XS module build not working for Perl 5.8
in thread XS module build not working for Perl 5.8

The error is: "Error: Can't load '/eng/proj/pacsun/DEV/MyPackage/blib/arch/auto/MyPackage/MyPackage.so' for module MyPackage: ld.so.1: /eng/proj/pacsun/TOOLS/bin/perl: fatal: relocation error: file /eng/proj/pacsun/DEV/MyPackage/blib/arch/auto/MyPackage/MyPackage.so: symbol cout: referenced symbol not found at /eng/proj/pacsun/TOOLS/lib/5.8.8/sun4-solaris-thread-multi/DynaLoader.pm line 230."

I think you might be educating me here ... I downloaded the Perl binary for 5.8.8 from ActiveState. This is the Perl that I am running and trying to build XS based modules in. Are you telling me that I must use the same compiler as ActiveState used to generate the binary? If so, how do I know what compiler they used?

I'm not sure I completely understand if this is true. While running 5.6, I would routinely create XS modules using C++ code. Typically I would compile using gcc. But Perl is compiled using some C compiler i.e. not gcc. I thought the XS generated library just created machine code and that the typemap dealt with passing data to and from the C/Perl object to your C++/XS object.

  • Comment on Re^4: XS module build not working for Perl 5.8

Replies are listed 'Best First'.
Re^5: XS module build not working for Perl 5.8
by ysth (Canon) on Aug 21, 2006 at 20:46 UTC
    I think you might be educating me here ... I downloaded the Perl binary for 5.8.8 from ActiveState. This is the Perl that I am running and trying to build XS based modules in. Are you telling me that I must use the same compiler as ActiveState used to generate the binary?
    In general, this is true, since the module build process will try to use compilers/linkers/options determined when perl was built. I know solaris has stuff to allow building modules with gcc via Solaris-PerlGcc, and recent ActiveState Win32 perl is supposed to also allow building modules with MinGW's gcc. But I don't know about ActiveState's Solaris perl or how any of those bandaids work with C++ modules.

    I'd really recommend building your own perl, perhaps starting with the Configure options given by perl -V:config_args on the perl you are using now. Also note that not many people build C++ modules, so IIRC that occasionally has been broken.

    How are you building your module now? It's starting to sound to me like you have your own makefile rather than having ExtUtils::MakeMaker build one; if so, you can expect breakage whenever perl's Config changes.

      I build them the usual way (I think). I run "h2xs -A -n MODULE_NAME". You have to make several edits to the files in the module to make them C++ compatible. This includes adding an XSOPT => '-C++' line to Makefile.PL. So the answer to the second question is that I am using MakeMaker, I just have to make a few changes to Makefile.PL. There is a good summary of the processs here: http://www.johnkeiser.com/perl-xs-c++.html I have tried to build my own Perl binary but I am having considerable problems. Let me run this by you and see what you think though ... in the past when this worked, I compiled using gcc. But for some unknown reason, gcc is broken at my site. So I have been using Sun's CC compiler instead. I wonder if this isn't the source of my problem?
        Ok ... the module built fine with perl 5.6. So if you take the exact same source that worked with 5.6 and try to build with perl 5.8, it fails ... right ? (There are exceptions, but you would generally expect that source code that compiles with 5.6 would also compile with 5.8.)

        So I have been using Sun's CC compiler instead. I wonder if this isn't the source of my problem?

        That could be the case (especially if 'perl -V:cc' returns "cc='gcc';"). What does 'perl -V:cc' return ?

        Cheers,
        Rob