Top Secret Area!!!

Recommended Sites
xgusties.com
craigmile.com
computers

Filesys::SmbClient on OS X

I've just spent a whole day trying to make this work. Arrrrghhh.

Issues

  1. Perl module Filesys::SmbClient requires libsmbclient.so (or libsmbclient.dylib on mac speak).
  2. OS X ships wil samba but no libsmbclient.dylib shared library.
  3. Fink and Darwin ports so not include libsmbclient.dylib with their samba packages.
  4. Unmodified samba source builds an OS X 'bundle' rather than a 'shared library' and this can not be linked against when building the perl module.

Resolution

Compile libsmbclient.dylib as a shared library

#get samba v3 source
cd ~/downloads
curl -O ftp://ftp.samba.org/.../samba-3.0.25pre1.tar.gz

#extract source
gunzip < samba-3.0.25pre1.tar.gz | tar xvf -
cd samba-3.0.25pre1/source
./configure

#patch Makefile
patch -b Makefile -
27,28c27,30
< LDSHFLAGS=-bundle -flat_namespace -undefined suppress -Wl,-search_paths_first
< WINBIND_NSS_LDSHFLAGS=-mbundle -flat_namespace -undefined suppress -Wl,-search_paths_first
---
> #LDSHFLAGS=-bundle -flat_namespace -undefined suppress -Wl,-search_paths_first
> LDSHFLAGS=-dynamiclib -fno-common -current_version 3.0 -compatibility_version 3.0 -fvisibility=hidden
> #WINBIND_NSS_LDSHFLAGS=-mbundle -flat_namespace -undefined suppress -Wl,-search_paths_first
> WINBIND_NSS_LDSHFLAGS=-dynamiclib -fno-common -current_version 3.0 -compatibility_version 3.0 -fvisibility=hidden
^D

#check that it compiled properly (look for DYLIB not BUNDLE)
otool -hv  bin/libsmbclient.dylib

#install dynamic library
cp includes/libsmbclient.h /usr/local/samba/lib/libsmbclient.h
cp bin/libsmbclient.a /usr/local/samba/lib/libsmbclient.a
cp bin/libsmbclient.dylib /usr/local/samba/lib/libsmbclient.dylib

#make sure that it knows where it is installed (an odd mac thing!)
install_name_tool \
	-id /usr/local/samba/lib/libsmbclient.dylib \
	/usr/local/samba/lib/libsmbclient.dylib

Fetch, Compile and install Perl Module


#install Filesys::SmbClient module
perl -MCPAN -eshell
cpan> look Filesys::SmbClient
sh% perl Makefile.PL
	libsmbclient.h [/usr/local/samba/include]
	libsmbclient.dylib [/usr/local/samba/lib/]
	test [no]
	debugging [no]
sh% make
sh% make install
sh% exit
cpan> exit

#make sure loadable modules know where shared lib is - may not be necessary
#install_name_tool \
#        -change bin/libsmbclient.dylib \
#        /usr/local/samba/lib/libsmbclient.dylib \
#        /Library/Perl/5.8.6/darwin-thread-multi-2level/auto/Filesys/SmbClient/SmbClient.bundle

p.s. this is my system

#test system
#Darwin MC-N328154.local 8.7.0 Darwin Kernel Version 8.7.0: Fri May 26 15:20:53 PDT 2006; root:xnu-792.6.76.obj~1/RELEASE_PPC Power Macintosh powerpc
uname -a