This section describes how to build dynamic and shared programs using the imake tool. See "Developing ChorusOS Applications" for more general information about using imake.
The following imake macro builds dynamic libraries:
DynamicLibraryTarget(dlib, objs, staticLibs, dynamicLibs, dlDeps, options)
dlib: name of resulting dynamic library (must be suffixed by .so).
objs: library components: list of binary object files (suffixed by .o).
staticLibs: list of static libraries (.a) that will be statically linked.
dynamicLibs: list of dependencies: dynamic libraries that must be loaded together with the resulting library. Each library can be defined in one of two ways:
-L path -l name : on the host, the linker will look for library path/libname.so. On the target, the runtime linker will look for libname.so in the library search path.
path: this is an absolute or relative library path used on the host by the linker, and on the target by the runtime linker. A relative path containing a / is interpreted as relative to the current directory by the runtime linker. A path without / is searched in the library search path by the runtime linker.
dlDeps: list of dynamic libraries the library depends upon. If these libraries are changed, the resulting library dlib will be rebuilt. Each library must be defined as a path on the host. Generally dlDeps duplicates the libraries described in dynamicLibs. This allows, when the -L path -l name syntax is used, to express the dependency without embedding a path in the executable.
options: any linker options, preceded by -Xlinker. This must be used to supply system-specific linker options which GNU C does not know how to recognize. If you want to pass an option that takes an argument, you must use -Xlinker twice, once for the option and once for the argument.
The following example builds a dynamic library named libfoo.so from the binary objects files a.o and b.o. When this library is loaded dynamically, the runtime linker will also load the dynamic library libdyn.so, which must be in its search path.
DynamicLibraryTarget( libfoo.so, a.o b.o, , libdyn.so, , )