|
17. Dynamic Loading
An increasingly popular way of adding functionality to a project is to
give a program the ability to dynamically load plugins, or modules. By
doing this your users can extend your project in new ways, which even you
perhaps hadn't envisioned. Dynamic Loading, then, is the process
of loading compiled objects into a running program and executing some or
all of the code from the loaded objects in the same context as the main
executable.
This chapter begins with a discussion of the mechanics of dynamic
modules and how they are used, and ends with example code for very
simple module loading on GNU/Linux, along with the
example code for a complementary dynamically loadable module. Once you
have read this chapter and understand the principles of dynamic loading,
the next chapter will explain how to use GNU Autotools to write portable
dynamic module loading code and address some of the shortcomings of
native dynamic loading APIs.
|