Looking for simple Makefile to make shared lib (.so) in Linux (I have two C files file1.c and file2.c, also two static libs slib1.a and slib2.a), can I get Makefile to compile all of them to crate final.so shared lib?.
I wrote this to compile using GNU compiler in Linux, this is not working, thanks in advance.
CC = gcc
AR = ar rc
CFLAGS = -Wall -g -O2 -I. -Iinclude -I../common/include -fPIC
OBJECTS = file1.o file2.o
SHARED_LIB = final.so
LIBS = -lslib1 -lslib2 -lpthread
$(SHARED_LIB): $(OBJECTS)
$(CC) $(SHARED_LIB) $(OBJECTS) $(LIBS)
%.o : %.c
$(CC) $(CFLAGS) -c $<
clean:
$(RM) $(OBJECTS)
$(RM) $(SHARED_LIB)
I wrote this to compile using GNU compiler in Linux, this is not working, thanks in advance.
CC = gcc
AR = ar rc
CFLAGS = -Wall -g -O2 -I. -Iinclude -I../common/include -fPIC
OBJECTS = file1.o file2.o
SHARED_LIB = final.so
LIBS = -lslib1 -lslib2 -lpthread
$(SHARED_LIB): $(OBJECTS)
$(CC) $(SHARED_LIB) $(OBJECTS) $(LIBS)
%.o : %.c
$(CC) $(CFLAGS) -c $<
clean:
$(RM) $(OBJECTS)
$(RM) $(SHARED_LIB)
Comment