3.3 clib2 versus newlib

Developers targetting the AmigaOS 4 platform can choose between two different C runtime libraries: clib2 and newlib. clib2 is linked statically into the binary whereas newlib is available as a shared library. Since Hollywood uses clib2 it is recommended that you use clib2 for your plugins as well. This can be achieved by compiling your sources with the following compiler setting:

 
gcc -mcrt=clib2 ...

Please note that clib2 is not thread-safe by default. Thus, if you need a thread-safe C runtime you need to link against clib2-ts instead, i.e.

 
gcc -mcrt=clib2-ts ...

If you want to use newlib for your plugins, you need to be very careful not to mix clib2 and newlib structures and handles. For example, all handles (e.g. an stdio FILE handle) allocated by Hollywood will be clib2 handles since Hollywood uses clib2. Thus, you must not pass them to a newlib stdio function since the internal representation of these handles might differ. Also, you must be careful when using structures that are shared between the C runtime provided by Hollywood and your plugin. Hollywood's C runtime will use the structures as defined in the clib2 headers whereas your plugin will use the format defined the newlib headers.

Finally, you also have to open newlib.library on your own if you want to use newlib in your plugin.


Show TOC