I have a problem that is causing me a headache, it is assumed that the command-L searches the libraries in the current directory of the Makefile, but it's not working for me, for example I have the following command in my Makefile:
... LDLIBS = -L/libs -lmatrix main: main.o operations.o display.o $(CC) $(LDLIBS) $^ -o $@ ... And when I try to compile it literally says:
gcc -L/libs -lmatrix main.o operations.o display.o -o main /usr/bin/ld: cannot find -lmatrix collect2: ld returned 1 exit status make: *** [main] Error 1 But when I simply change "-L/libs" for "-L$(PWD)/libs" it compiles perfectly and my program works fine...
But using "-L$(PWD)" I get another problem, if the name of any directory has a space It doesn't work again, actually I don't know if this problem is irremediable (using $(PWD) or not), but I still have the doubt that why it doesn't work without the $(PWD) because apparently (seeing A LOT of examples on the internet) using -L, the $(PWD) shouldn't be needed.