fedora 22 multiple undefined reference errors when linking shared object
I am trying to compile a C language library as a shared object on my new install of Fedora 22. The project compiled fine on my old install of Fedora 20. But now, when I run my makefile:
CC=gcc vpath %.c src vpath %.h inc CFLAGS = -fPIC INCLUDE = -Iinc -I/usr/include -I/usr/local/include LIBPATH = -L/usr/lib -L/lib64 LIBS = -lportaudio -lm -lpthread -ldl OBJ_PATH = ./objs SRCS = my_code1.c my_code2.c # etc. OBJS = $(SRCS:.c=.o) .PHONY: libmylib.so all: libmylib.so debug: $(CFLAGS) += -DDEBUG -O0 -g3 -DPD debug: all release: $(CFLAGS) += -DTESTING -O2 -DPD -funroll-loops -fomit-frame-pointer release: all %.o: %.c $(CC) $(CFLAGS) $(INCLUDE) $(LIBPATH) $(LIBS) -c -o $@ $^ libmylib.so: $(OBJS) $(CC) -shared -Wl,-soname,libmylib.so \ -Wl,--no-undefined $(OBJS) -lc -lportaudio -ldl -lm -lpthread mv libmylib.so ./bin mv *.o $(OBJ_PATH) clean: rm $(OBJ_PATH)/*.o rm bin/libmylib.so
I get very many undefined reference errors:
my_code1.o: In function `func_in_my_code1': my_code1.c:(.text+0x1b8): undefined reference to `func_from_my_code2' my_code2.o: In function `func_in_my_code2': my_code2.c:(.text+0x310): undefined reference to `func_from_my_func1'
The functions in question are most certainly defined in the code. Presumably these are compiled into .o files in the compile stage.
The exact same build environment worked on my previous fedora installation. I am at a loss as to why I should get these errors.
Also, if I compile without the -Wl,--no-undefined flag, it compiles fine, but when I try to load the library from another application, it tosses the same set of undefined errors.
This may have nothing to do with the new version of Fedora. It is possible that there are some environment variables or something that didn't make through to my new install, but I have no idea what they could be.
Apparently I now need to insert the extern keyword into these functions. The code compiled and ran perfectly well before... I would like to reiterate, for posterity's sake, that I did post the entire makefile in my question.