c/c++导出动态库Makefile

示例

$(CXX) = g++
$(CC) = gcc

COMPILE_FLAGS := -fPIC -O2 -Wall -Wextra -shared
INCLUDES := -I.
OBJECTS := *.o
SRC_kgsl := ./kgsrc/

# .PHONY: default_target
# default_target: release
objects = Test_EncodeDecode.o \
		  NetCompress.o \
		  lzf_c.o \
		  lzf_d.o \
		  TestWorld.o

libTestWorld.so : $(objects)
	$(CXX) $(COMPILE_FLAGS) $(objects) -o libTestWorld.so

Test_EncodeDecode.o : Test_EncodeDecode.cpp
	$(CXX) $(COMPILE_FLAGS) $(INCLUDES) -c $<
lzf_c.o : lzf_c.c
	$(CC) $(COMPILE_FLAGS) $(INCLUDES) -c $<
lzf_d.o : lzf_d.c
	$(CC) $(COMPILE_FLAGS) $(INCLUDES) -c $<
NetCompress.o : NetCompress.cpp
	$(CXX) $(COMPILE_FLAGS) $(INCLUDES) -c $<
TestWorld.o : TestWorld.cpp
	$(CXX) $(COMPILE_FLAGS) $(INCLUDES) -c $<

clean:
	rm libTestWorld.so -rf
	rm *.o -rf

c/c++导出动态库示例

你可能感兴趣的:(C/C++,Linux)