963 cd linker_demo # build hello.c with static linking of standard library 964 vim Makefile 963 make static_hello 968 nm static_hello # build hello.c with dynamic linking of standard library (default) 970 make dynamic_hello # the executable with statically linked standard library has far more symbols. # For example, it contains the printf definition (and helper function definitions) 974 nm static_hello | wc -l 972 nm dynamic_hello | wc -l 977 ls -l *_hello 978 cd .. 979 cd archive_demo 1141 ls 1143 vim Makefile # run the archive tool (ar) to wrap up speak.o and shout.o into # one .a, or "library", or "archive" 1144 make libvoices.a # link to the libvoices.a instead of speak.o and shout.o 1145 make talk 1146 ./talk # The gnu linker processes .o's and archives left to right # so if you use the wrong order then you will still get # "undefined reference to speak/shout" errors (see 21-linking-more.pdf slide 5-6) 1147 make talk-wrong-order 1135 history >lec21.history