layout: true
Class 9: Libraries
--- class: center, middle # Libraries ### Class 9 --- # Overview 1. Announcements 2. Review 3. Q&A 4. Basic assignment --- # Announcements * Python assignments due November 29 * Libraries assignments due November 29 * (Extra) Text Editors assignments due November 29 * (Extra) Debugging assignments due December 6 * No office hours next week! -- * People who have set up personal projects will need to submit them by December 8 11:59 PM EST * Last time to submit assignments will be December 15 11:59 PM EST, full stop. * I will be running the scripts to calculate and bundle grades for WolverineAccess after -- * `eecs201-test calculate` can give you your accurate current total --- # Review * Static libraries go directly inside the executable * Libraries are an inherent part of the executable * Dynamic/shared libraries are referred to by the executable * Libraries are loaded at load/runtime --- # Review * Really easy to link a library * Toss `-lname` _at the end of compilation command_ * `-lpng` for `libpng.so` or `libpng.a` * `-lm` for `libm.so` or `libm.a` * (Linux) `-l:libname.a` is an explicit way to specify library file to link * `-Ldir` can specify additional directories to look for libraries * You can also link against a library by providing the path to the library file as an argument (particularly useful for static libraries) --- # Review ### Creating a library * Create object code with `-c` * e.g. `gcc -c -o file.o file.c` * Dynamic library object code requires `-fPIC` flag * e.g. `gcc -c -fPIC -o file.o file.c` * Static: `ar rcs libname.a file.o` * Dynamic: `gcc -shared -o libname.so file.o` --- class: center, middle # Q&A --- class: center, middle # Basic assignment