# 1、准备工作,编译方式、目标文件名、依赖库路径的定义。
CC = g++CFLAGS := -Wall -O3 -std=c++0x
# opencv 头文件和lib路径
OPENCV_INC_ROOT = /usr/local/include
OPENCV_LIB_ROOT = /usr/local/lib64
# ffmpeg 头文件和lib路径
FFMPEG_INC_ROOT = /usr/local/ffmpeg/include
FFMPEG_LIB_ROOT = /usr/local/ffmpeg/lib
# mysql 头文件和lib路径
MYSQL_INC_ROOT = /usr/include/mysql
MYSQL_LIB_ROOT = /usr/lib64/mysql
OBJS = key_Frame.o
LIB = libKeyFrame.so
OPENCV_INC= -I$(OPENCV_INC_ROOT)
FFMPEG_INC= -I$(FFMPEG_INC_ROOT)
MYSQL_INC = -I$(MYSQL_INC_ROOT)
INCLUDE_PATH = $(OPENCV_INC)
INCLUDE_PATH_FFMPEG = $(FFMPEG_INC)
INCLUDE_PATH_MYSQL = $(MYSQL_INC)
LIB_PATH = -L$(OPENCV_LIB_ROOT)
LIB_PATH_FFMPEG = -L$(FFMPEG_LIB_ROOT)
LIB_PATH_MYSQL = -L$(MYSQL_LIB_ROOT)
# 依赖的lib名称
OPENCV_LIB = -lopencv_dnn -lopencv_flann -lopencv_videoio -lopencv_videostab -lopencv_superres -lopencv_video -lopencv_ml -lopencv_photo -lopencv_shape -lopencv_stitching -lopencv_calib3d -lopencv_features2d -lopencv_imgcodecs -lopencv_objdetect -lopencv_core -lopencv_highgui -lopencv_imgproc
FFMPEG_LIB = -lavcodec -lavformat -lavutil -lavdevice -lavfilter -lswscale -lswresampleMYSQL_LIB = -lmysqlclient
all : $(LIB)
%.o : %.cpp
$(CC) $(CFLAGS) -fpic -c $< -o $@ $(INCLUDE_PATH) $(LIB_PATH) $(OPENCV_LIB) $(INCLUDE_PATH_FFMPEG) $(LIB_PATH_FFMPEG) $(FFMPEG_LIB) $(INCLUDE_PATH_MYSQL) $(LIB_PATH_MYSQL) $(MYSQL_LIB)
$(LIB) : $(OBJS)
rm -f $@
g++ -shared -o $@ $(OBJS)
rm -f $(OBJS)
tags :
ctags -R *
PHONY:clean
clean:
rm -f $(OBJS) $(TAGRET) $(LIB)