Next: , Previous: Working With Desktop GUI Applications, Up: Command Line Use


5.4 Working With Libraries

Compiling a library enables you to modularize your code by putting common routines in one place so that different applications may make use of them without reimplementing the same functionality. In Open Source PHP, this is normally done through the use of the include and require directives. Roadsend PHP emulates this behavior but also allows those included files to be precompiled libraries rather than interpreted scripts.

resources/using-libs.png

Compiling Libraries

To create a compiled library, call pcc with the -l switch, followed by a library name, then the list of source files to be included in the library.

     pcc -l libraryname <file1 file2 ... fileN>

For example, to make a library named test-lib call

     pcc -l test-lib libfile1.php libfile2.php libfile3.php

This would produce a binary library file (such as "libtest-lib.so" on Linux) that would contain the compiled routines from the source files libfile1.php, libfile2.php and libfile3.php.

Roadsend PHP will create a binary object file (.o) for each source file in the library. If you change a source file and wish to rebuild the library, Roadsend PHP will only recompile those files that have changed. You can force a full rebuild with the --force-rebuild option.

The files important for installation and deployment generated during a library build include: