I'm trying to add a .so library to my project, but my knowledge in makefiles are very limited, and I unfortunately don't understand the tutorial I could find...
Here is the structure of my project :
/project ex1.c ex1.h ex1_client.c ex1_client.h /lib libmylib.so I need to use mylib in ex1 and ex1_client, two executables, but I don't success in including it in the makefile (and I'm thinking I may not know how to include it in my .c files...)
My makefile is :
CC= gcc CFLAGS= -Wall -pedantic -std=c99 -pthread RM= rm -f LFLAGS= -L./lib LIBS= -lmylib #Don't know if the following is necessary LD_LIBRARY_PATH= ./lib all: ex1 ex1_client ex1: ex1.o $(CC) $(CFLAGS) -o ex1 ex1.o $(LFLAGS) $(LIBS) ex1_client: ex1_client.o $(CC) $(CFLAGS) -o ex1_client ex1_client.o $(LFLAGS) $(LIBS) ex1.o: ex1.c ex1.h $(CC) $(CFLAGS) -c ex1.c ex1.h ex1_client.o: ex1_client.c ex1_client.h $(CC) $(CFLAGS) -c ex1_client.c ex1_client.h clean: $(RM) *.o ex1 ex1_client *~ It doesn't work - seems to don't know where to find mylib, or juste don't know it has something to find.
In addition of that, I didn't write anything about mylib in my .c files... I mean no #include. Probably one of all of the problems.
Explanations about libraries and makefiles seems really hard to me to understand... and please excuse the school-learned english of a young french developper ;)
libXYZ.so; GCC knows this, and is expecting flags of the form-lXYZ.libmylib.so.