Programming and Graphics

(Kiana) #1

7.1 Compilation 199


oliver: oliver.cc
c++ -o oliver oliver.cc -lX11 VOGLE/voglelinuxansi.a

and issue the command:


make oliver

The compiler options shown in the second line of the makefile have the following
meanings:



  • The option-o oliverrequests that the binary executable file named
    “oliver” be generated after compilation.

  • The option-lX11requests that the librarylibX11.sobe linked with the
    object file of the oliver.cc code when producing the executable.


More generally, the compiler option-lpindos requests that a library
namedlibpindos.aorlibpindos.sobe linked with the object of the source
code. The suffix “a” denotes an archival static library, and the suffix
“so” denotes a dynamically shared object. The search directories during
linking include several standard system directories listed in the system
archiveliblibrary.a


  • The entryVOGLE/volgelinuxansi.arequests that theVoglelibrary
    vogleansi.abe linked with the object file of the oliver.cc code to form the
    executable.


It has been assumed thatvogleansi.ahas been placed in the subdirec-
toryVOGLEof the current working directory. This directory location is
arbitrary and can be replaced by any other convenient location, provided
that access permissions have been granted.

In summary, the object file of our source code will be linked statically with the
Voglelibrary and dynamically with the X11 library. An equivalent makefile
is:


oliver: oliver.cc
c++ -o oliver oliver.cc -lX11 -lvoglelinuxansi -LVOGLE

The compiler option-LVOGLEadds theVogledirectory to the list of library
search directories.


In the cygwin environment inside Windows, we use the makefile:

oliver: oliver.cc
c++ -o oliver oliver.cc VOGLE/voglecygwinansi.a \
-lX11 -lm -L/usr/X11R6/lib
Free download pdf