Ex30 Automated Testing Framework - undefined reference to

After setting up the automated testing framework and checking that it works correctly by running the stubs (code found under ex30.c), I include the actual test (code found under libex29_tests.c) and I keep getting this error everytime I run ‘make all’ or ‘make tests’ once the build has completed:

It appears that the #include <dlfcn.h> directive is not picking up this header file, resulting in the undefined reference problem.

Has anyone experienced this before?
I am using Ubuntu 20.04.1 and gcc 9.4.0

iIt seems this is a known issue with GCC on linux:

The solution is to add “-Wl,–no-as-needed -ldl” to the CFLAGS for tests in the Makefile.

This works.