Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Matts (1087)

Matts
  (email not shown publicly)

I work for MessageLabs [messagelabs.com] in Toronto, ON, Canada. I write spam filters, MTA software, high performance network software, string matching algorithms, and other cool stuff mostly in Perl and C.

Journal of Matts (1087)

Friday August 02, 2002
11:43 AM

Combining libs on OSX

[ #6868 ]

In XML::LibXML and XML::LibXSLT we share memory allocation code by simply copying the perl-mm.c files between the two projects (yes this is naive, but it works). This works fine on all OSes except Mac OSX, apparently, where it complains about multiple definitions.

So I tried making the memory allocation code external (this'll work no problem I thought to myself!). But it doesn't like that either because it can't find the code now. Gah!

So has anyone got any idea how I might fix this?

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • For the Mac:: stuff, I defined the same function names and variables in multiple shared libraries, and dyld complained mightily. I put the functions in a single XS file, and access them from the others. So, for example, Foo.xs defines Foo(), and Bar.xs calls Foo() freely, and I put use Foo; at the top of Bar.pm, Baz.pm, etc. And, of course, Bar.xs has to include "../Foo/Foo.h" to get the definition ...

    Does that sound like what you were running into? And does my approach seem Wrong? I don't do a lot of C or XS ... I just look for something that works, and this seems to.
  • I bounced off this the other day, I eventually realised I could use the linker against itself and deleted the .c file from the XML::LibXSLT tree.

    The symbol leaks over when LibXSLT.pm uses LibXML and it just magically works out.

    • That totally doesn't work for me - I get:

      dyld: /usr/bin/perl Undefined symbols:
      _PmmSvNode

      Which is one of the functions.

      (and yes, XML::LibXML is loaded before XML::LibXSLT is bootstrapped).
      • Hmm, I guess this is probably that I'm building against a locally-built 5.8.0 rather than the supplied 5.6.0.

        Looking at the output of perl -V for both perls their linker flags do differ, which could explain it:

        /usr/bin/perl (5.6.0)
        Linker and Libraries: ld='cc', ldflags =''

        perl5.8.0

        Linker and Libraries:
            ld='cc', ldflags =' -flat_namespace'

        The Dynamic Linking linker options lddlflagsall are the same for both perls, so I suspect it's the differing ldflags that are letting i