Questions: Linking and Loading

4 questions to test your understanding

Score: 0 / 4
Question 1 Multiple Choice

A C program that calls sqrt compiles each .c file without errors, but the build fails with "undefined reference to `sqrt'". Which stage reported the error, and what is the usual fix on Linux?

AThe preprocessor; add #include <math.h>
BThe compiler's type checker; cast the argument to double
CThe linker; link the math library, for example by adding -lm
DThe loader; run the program with administrator rights
Question 2 Multiple Choice

What does relocation do during linking?

AIt moves source files into the same folder
BIt assigns run-time addresses to code and data sections and patches each reference so it points to the correct final address
CIt deletes unused functions from the source code
DIt moves the program from disk into memory at run time
Question 3 True / False

When a program is dynamically linked against a shared library, the library's machine code is copied into the program's executable file at link time.

TTrue
FFalse
Question 4 Short Answer

Give two advantages of shared (dynamically linked) libraries over static libraries.

Think about your answer, then reveal below.