C.3.  Understanding the Linker

[ fromfile: linker.xml id: linker ]

Figure C.1.  The Linker's inputs and outputs

The Linker's inputs and outputs

Example C.4. linker-invocation.txt

    g++ -Wl,-rpath,/usr/local/qt-x11-free-3.2.3/lib           1 
        -o hw7                                                2
        .obj/address.o .obj/ca_address.o .obj/constraintgroup.o
        .obj/customer.o .obj/dataobject.o .obj/dataobjectfactory.o
        .obj/hw07-demo.o .obj/us_address.o .obj/moc_address.o 3
        .obj/moc_ca_address.o .obj/moc_customer.o .obj/moc_dataobject.o 
        .obj/moc_us_address.o  
        -L/usr/local/qt-x11-free-3.2.3/lib  -L/usr/X11R6/lib 
        -L/usr/local/utils/lib                                4
        -lutils -lqt -lXext -lX11 -lm                         5

1

Tells g++ to run the linker, and pass these options to ld.

2

Specify the output to be called hw7.

3

Link these object files into the executable.

4

Add another location for the linker to search for libraries.

5

Link this app with five more libraries: qt utils, ext, X11, and m.