[Q] Compiling external plugin OSX Panther xcode

John M McIntosh johnmci at smalltalkconsulting.com
Thu Mar 11 01:08:02 UTC 2004


You should go look at the printjob plugin or the mpeg plugin for os-x  
found in the mac source tree.

If there is a Plugins folder in the same folder as the Squeak  
3.7.2Beta1.app application it will look for the plugin there, otherwise  
we
look in the same folder as the application.

For OS-9 users we also hunt for the plugin as a shared library using  
the os-9 how to find a shared library rules (long complicated) with  
special
places to look based on bugs from mac os versions from the  80's.

However since you are using OS-X we then consider just looking in the  
same directory or the plugins folder.

So then we we are looking for a BUNDLE. In fact if we say we are  
looking for mpeg3Plugin  we actually look for

mpeg3Plugin.bundle  via Apple's CFBundleCreate() see their docs for  
what that does.

Ah, but what if mpeg3Plugin is a FRAMEWORK? If so we retry looking for  
mpeg3Plugin  as a framework, the framework then needs to be found in  
the places you would put frameworks. I recall I added this feature so  
you could call OpenGL from croquet, or Quicktime. Although some  
frameworks have ".framework" in the name, I don't believe you need this  
file ending.

For both cases we then invoke CFBundleLoadExecutable()
  " Loads a bundle's main executable code into memory and dynamically  
links it into the running application."

If any errors happen when resolving what we think the path name to the  
file, and what the bundle/framework name is called within that path,  
why we abort.

I'll note that according to the docs
/* ==================== Primitive Code Loading API ====================  
*/
/* This API abstracts the various different executable formats  
supported on */
/* various platforms.  It can load DYLD, CFM, or DLL shared libraries  
(on their */
/* appropriate platforms) and gives a uniform API for looking up  
functions. */
/* Note that Cocoa-based bundles containing Objective-C or Java code  
must */
/* be loaded with NSBundle, not CFBundle.  Once they are loaded,  
however, */
/* either CFBundle or NSBundle can be used. */


Note that CFM users (if you don't know what that is then stop reading)  
will find some code at MachOFunctionPointerForCFMFunctionPointer(),  
it's broken, the usable code is in the Squeak NSPlugin stub for CFM to  
Mach-O interfacing. At one point I considered allowing you to call CFM  
plugins from Mach-O squeak, but no one wanted it....

PS if you download and compile a development version of the mac os-x VM  
under x-code this will all become clearer, and as a side effect you  
will be able to see what errors you get when the bundle loads, because  
there is no real feedback to the invoking smalltalk method why the DLL  
call failed.

Technically once could generate an event and toss it on the event queue  
to be passed up to Smalltalk, that might be an interesting thing to do?

On Mar 10, 2004, at 12:25 PM, Jamie Gjerde wrote:

> Hello,
>
> I recently compiled and have working a simple dll plugin for windows  
> 2000 that is communicating with the squeak vm. I am now trying to  
> compile the same external plugin on OSX Panther with xcode. I can get  
> the library compiled, but all I get is a single executable when I  
> build. From what I have seen from the other external plugins in the  
> plugins folder, they also each have a .bundle file along with the  
> executable which i do not get from my build.
>
> Basically, I am looking for some sample configuration on how to  
> compile a stand alone library and get the squeak vm to recognize it on  
> OSX panther with or without xcode. This is a direct port from the  
> windows plugin that I have already compiled. And remember the code  
> itself is fine, it does compile, it is some extra config in the build  
> process that I must be missing.
>
> Jamie
>
>
>
--
======================================================================== 
===
John M. McIntosh <johnmci at smalltalkconsulting.com> 1-800-477-2659
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
======================================================================== 
===




More information about the Squeak-dev mailing list