Combining libs on OSX

Matts on 2002-08-02T16:43:11

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?


That sounds like what I ran into yesterday

pudge on 2002-08-02T17:02:08

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.

Re:That sounds like what I ran into yesterday

Matts on 2002-08-02T19:25:07

That sounds like it might work. I'll give it a try.

Re:That sounds like what I ran into yesterday

sky on 2002-08-02T22:33:43

Not really wrong, however if you are porting alot of code that might not be possible, a good trick then is to disable -flat-namespace

Re:That sounds like what I ran into yesterday

pudge on 2002-08-03T03:23:18

Ahhh. Hm. But I wonder if I can even compile the rest of it without -flat-namespace, as my code is relying on Carbon's flat headers. Bah.

Kill, kill them all

richardc on 2002-08-03T00:01:44

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.

Re:Kill, kill them all

Matts on 2002-08-03T09:07:00

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).

Re:Kill, kill them all

richardc on 2002-08-03T11:39:05

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 it work for me.

Re:Kill, kill them all

richardc on 2002-08-03T11:41:20

doh, hit save rather than preview. I mean lddlflags not lddlflagsall