Next: , Previous: , Up: Features  

2.6 Dynamic loading

The DLD class enhances the C callout mechanism to automatically look for unresolved functions in a series of program-specified libraries. To add a library to the list, evaluate code like the following:

     DLD addLibrary: 'libc'

The extension (.so, .sl, .a, .dll depending on your operating system) will be added automatically. You are advised not to specify it for portability reasons.

You will then be able to use the standard C call-out mechanisms to define all the functions in the C run-time library. Note that this is a potential security problem (especially if your program is SUID root under Unix), so you might want to disable dynamic loading when using GNU Smalltalk as an extension language. To disable dynamic loading, configure GNU Smalltalk passing the --disable-dld switch.

Note that a DLD class will be present even if dynamic loading is disabled (either because your system is not supported, or by the --disable-dld configure switch) but any attempt to perform dynamic linking will result in an error.