Download The Omega Library - Computer Science
Transcript
Chapter 2 Compiling And Running Programs With The Omega Library 2.1 Introduction To use the Omega Library in an existing C++ application, it is necessary to: Use the makele included in the release to make libomega.a if it doesn't already exists. Include -lomega as an option to the linker. Include -Ldir as an option to the linker, where dir is a directory that contains libomega.a. Add the line #include "omega.h" to each application source le that references Omega library data structures or functions. If the include le omega.h and the associated omega subdirectory have not been placed in a standard include directory on your system, use -Idir/include as an option to the compiler, where dir is a directory that contains the include directory from this release. Make any modications that are needed to get the Omega Library and your code to compile with compatible compilers (see Section 2.3). 2.2 Avoiding Name Collisions Some of the global names in our library are simple enough that they may conict with names used in your code or some other library you use. We have taken the following steps to ensure that such conicts can be resolved easily - these are based on vague memories of something from the documentation of the InterViews project, so to the degree that the approaches are similar, that project should get the credit. In a header le that denes an obvious name, such as String, we replace (via #define) that name with some less obvious name, such as Omega String. This ensures that these obvious names do not appear in the library, even though we use them in our code. In case of conict, just #undef the obvious name after the inclusion of omega.h, but before the inclusion of the header le that causes the conict. For example, if you need to use both the Omega Library and Motif (which denes the name String), rst #include omega.h, then #undef String (or, alternatively, #include omega/basic/leave String.h, which does this), and then #include the necessary Motif header les. If you nd a conict in a header that we have not prepared as described above, let us know so that we can x this in the next release. In the meantime, it should be fairly easy to install this x yourself and re-compile. 6