[Vm-dev] How to link dynamic library into a Squeak plugin on Mac Intel

Simon Holland s.holland at open.ac.uk
Mon Aug 27 10:35:20 UTC 2007

Bert Freudenberg-2 wrote:
> On Aug 25, 2007, at 16:54 , Simon Holland wrote:
>> Can anyone point to any examples or info on how to
>> link a dynamic library into a Squeak plugin  build on Mac Intel?
>> None of the following work
>> /Users/simon/squeak/platforms/unix/plugins/PortMidiLitePlugin/i386/ 
>> libportmidi.dylib
>> PLIBS=$PLIBS /usr/local/lib/libportmidi.dylib
>> PLIBS=$PLIBS  -dynamiclib -Wl,-single_module -Wl,-install_name,
>> /usr/local/lib/libportmidi.dylib
>> PLIBS=$PLIBS  -dynamiclib -Wl,-single_module -Wl,-install_name,  
>> lportmidi
>> PLIBS=$PLIBS   lportmidi
>> (They compile fine but fail to load)
>> libportmidi.dylib is installed in /usr/lib
>> and the environment  variable
>> DYLD_LIBRARY_PATH is set to /usr/local/lib
>> Recasting the plugin as a command line C application,
>> and dropping the relevant dylib into the  XCode window
>> works with no bother.
>> Cheers
>> Simon
> Last time I needed to do this I started with the XCode project for  
> another plugin from SVN, modified it for my plugin, and just added  
> the libs to it. Don't remember the details though.
> - Bert -

Thanks Bert!

In case anyone should be looking for the answer  at a later date, here is
how to create an external squeak plugin on intel mac that links into an
external library (e.g. a dylib or .a static library).

1/ Use xcode to make a carbon bundle project from scratch.

2/ Apart from your plugin code and your external library you will need to
add the exactly correct minimum set of  (slightly edited) vm header files.

3/ The set of headers  and the necessary edit has been documented in
Japanese by the Takashi Yamamiya
and written up  in English by Gerald Leeb http://g-24.net/squeak/ode.html.

4/ If you then run a conventional unix vm/plugin  macintel build  for your
plugin using a plugin Makefile.inc of 
PLIBS=$PLIBS  -L/usr/local/lib  -dynamiclib -Wl,-single_module
-Wl,-install_name, lportmidi. 
(in my case, given that I was linking to portmidi and put the dylib in that
location )
then the plugin will end up in the package contents of the VM.

4a/ Instead of step 4 you can just manually drop the plugin into the package
contents of  a VM of the right version number, which I assume is the normal
deployment route.

Thanks all!


View this message in context: http://www.nabble.com/Newbie-problem-porting-PortMidi-to-Squeak--%28Mac-Intel%29-tf4324379.html#a12344712
Sent from the Squeak vm-dev mailing list archive at Nabble.com.

More information about the Vm-dev mailing list