Basic - Libraries Fall 2026
Submission Instructions
This homework will be submitted as a repository on the EECS GitLab
server. The repository you submit will be a private Project with
the name/path eecs201-basic-lib with akamil added as a Reporter. The branch lib
will be the one that is checked.
To finish the submission process and get your submission score, you will need to run the autograder. You will need to SSH into the course server (see Basic - Intro):
local$ ssh uniqname@peritia.eecs.umich.edu
(the local$
referring to a shell prompt on your system)
and then run eecs201-test:
peritia$ eecs201-test basic-lib
(the peritia$
referring to a shell prompt on the server)
Preface
In this assignment you’ll be provided yet another zipped archive containing some starter files.
https://www.eecs.umich.edu/courses/eecs201/fa2026/files/assignments/basic-lib.tar.gz
Extract the archive and
cd into the created
directory. If you run
ls you should see the
create and
link directories.
Note that this assignment is to be submitted on a remote branch called
lib. Initialize a Git
repository inside of the extracted
basic-lib
directory; as noted above
git init -b <branch name>
or
git init --initial-branch <branch name>
can initialize the repo with a different branch name (e.g.
lib as per the
submission instructions). If your version of Git is too old for these
options, you could create the
lib branch afterwards
after your first commit, or you can set the local branch’s tracking
information manually. Create a file called
report.txt in this
directory.
Add all of the present files and commit them.
Create a private project named
eecs201-basic-lib on
the UMich GitLab
(gitlab.eecs.umich.edu)
and add the instructor
akamil as a
Reporter. Set this UMich GitLab project as your remote: you’ll be
pushing to it in order to submit.
This homework assignment assumes that you have a basic understanding of Makefiles. If you did not do Basic - Make or Advanced - Make, you may want to get brushed up on Makefiles.
Linking against libraries
In this section you’ll be linking against a static library and its dynamic version with two different targets.
-
cdinto thelinkdirectory. -
Run the
getlib.shscript. This script identifies your operating system and architecture to locate and create links to the appropriate provided library files, putting down thelibthingy.soandlibthingy.asymlinks in thelinkdirectory. -
Open the
Makefile. Note the two TODOs. -
As a foreword for Mac users, the
-l:libname.astyle of linking doesn’t work with the default toolchain on macOS. If you want to link a static library, you can simply provide the path to the static library file as an argument, just as if it were a source code file e.g.gcc -o file1.c libname.a. -
Address the two TODOs and modify the compilation commands so that the
app-dynamictarget links againstlibthingy.soand theapp-statictarget links againstlibthingy.a.
When there’s a naming conflict, which takes precedence? -
You can use the
run-dynamicandrun-staticrules to see if you successfully linked against the dynamic and static libraries e.g. running$ make run-dynamic. For Linux/WSL users, try runninglddon your executables to see if they dynamically linked the libraries. For Mac users, you can useotool -Lto provide similar information about your executables.For Mac users, if you get an error that
libthingy.socould not be verified, click on “Done” repeatedly until the program exits. Then open up the System Settings app, navigate to Privacy and Security, and scroll down to where it says thatlibthingy.sowas blocked. Clink on Allow Anyway. Then try running again and clock on Open Anyway if you get another popup.
Creating libraries
In this section you’ll be performing the steps to build both a static library and a dynamic library.
-
cdinto thecreatedirectory. -
Take a look at the directory structure.
-
The
incdirectory contains library header(s). -
The
libsrcdirectory contains the source code for the library. -
The
libdirectory (created by the Makefile) contains produced libraries.
-
-
Open the
Makefile. Note the four TODOs. -
Add the necessary commands to the appropriate recipes to build the object code for the dynamic and static libraries, the dynamic and static libraries themselves, and like in #1, update the
app-dynamicandapp-statictargets to link against the appropriate libraries. For Mac users, remember that-l:libname.astyle linker arguments don’t work, and to provide the path to the static library as a normal file argument.-
Note that dynamic/shared library objects need to be compiled as position-independent code.
-
Note that the object code has separate rules in the Makefile.
-
Conclusion
-
Add and commit the files you modified.
-
Fill out the
report.txtfile in the following steps: -
On the first line provide an integer time in minutes of how long it took for you to complete this assignment. It should just be an integer: no letters or words.
-
On the second line and beyond, write down what you learned while doing this assignment. If you already knew how to do all of this, put down “N/A”.
-
Commit your
report.txtfile and push your commits to your remote. -
Run the autograder!