opencv Linux链接库,linux C++调用opencv测试类编译成链接库

# 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)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值