Reputation: 870
I have a C program with a path like this :
pgrmusinglib.c
pgrmusinglib.h
main.c
libfolder
I am trying to compile it on windows using mingw64. I built this Makefile
CC = gcc
CFLAGS = -O3
DEPS = pgrmusinglib.h
LDFLAGS = -L/$(LIB) -lmylibrary
LIB = libfolder
SRC=$(wildcard *.c)
OBJ = $(SRC:.c=.o)
all: pgrm
pgrm : $(OBJ)
$(CC) -o $^ $(LDFLAGS)
%.o: %.c $(DEPS)
$(CC) -c $^ $(CFLAGS)
The pgrm rule fails with error :
c:/programdata/chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
cannot find -lmylibrary
Upvotes: 0
Views: 732
Reputation: 238
I believe it is'nt working because of how you wrote the LDFLAGS, just a little typo I assume, you put a '/' in front of the directory name , so its looking for libfolder in your root directory. Try either removing the '/' or putting a period '.' In front of it
Upvotes: 1