I'm having some issues with a Makefile for a project I am working on. I am getting "undefined reference to 'timer_create'" and such even though they are included in the linkopts. I think the issue is that the libraries are at the front of the compile line instead at the end, but I am pretty unfamiliar with a Makefile like this. How can I ensure the links come at the end instead of at the beginning? Here is part of the Makefile I am talking about, the make, it tries this:
gcc -g -lpthread -lrt -Wall -o scheduler scheduler.o worker.o list.o smp5_tests.o testrunner.o
But I am pretty sure it should be this:
gcc -g -Wall -o scheduler scheduler.o worker.o list.o smp5_tests.o testrunner.o -lpthread -lrt
Here is the Makefile:
CC = gcc
CCOPTS = -c -g -Wall
LINKOPTS = -g -lpthread -lrt -Wall
EXEC=scheduler
OBJECTS=scheduler.o worker.o list.o smp5_tests.o testrunner.o
all: $(EXEC)
$(EXEC):$(OBJECTS)
$(CC) $(LINKOPTS) -o $@ $^