[sf-perl] Building File::LibMagic on OS X

Bill Moseley moseley at hank.org
Tue Jun 26 07:36:59 PDT 2012

I need some help understanding how to build the File::LibMagic module on OS
X 10.6.

I've installed Libmagic using homebrew.  The homebrew formula used:

Now the header and lib ended up in odd places:

$ find /usr/local -name libmagic\*

$ find /usr/local -name magic.h | grep -v Image

I seem to be able to build the Perl module like this:

$ perl Makefile.PL INC=-I/usr/local/Cellar/libmagic/5.04/include

"make" seems to run fine, but, the tests fail with this:

Can't load
for module File::LibMagic:
2): Symbol not found: _magic_buffer
  Referenced from:
  Expected in: dynamic lookup

That symbol is in the libmagic library:

$ nm  -gU /usr/local/Cellar/libmagic/5.04/lib/libmagic.1.dylib | grep
0000000000000fc0 T _magic_buffer

My guess is runtime isn't linking to libmagic.1.dylib (IIRC, OS X doesn't
have a default search path), but if that was the case then I would think
I'd see an error about not finding the library at run time.

And that's the limit of my OS X knowledge.  If "otool -L" is similar to
"ldd" then doesn't look like it's linked at all with libmagic, right?

$ otool -L
 /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version


Bill Moseley
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/sanfrancisco-pm/attachments/20120626/16879760/attachment.html>

More information about the SanFrancisco-pm mailing list