https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90399
--- Comment #1 from Martin Karsten <mkarsten at uwaterloo dot ca> --- Sorry, I accidentally included a version of the Makefile that I had used for testing and that contains the flag '-nodefaultlibs' when building the library. This leads to other problems. The correct Makefile is: CXXFLAGS=-fPIC -fsplit-stack main: main.o libtest.so g++ $< -o $@ -L. -ltest works: main.o test.o g++ $^ -o $@ libtest.so: test.o g++ -shared $^ -o $@ clean: rm -f main works main.o test.o libtest.so