Makefile笔记
作者:互联网
编译链接:引用非本文件的变量是在连接时进行定位的,大佬博客https://www.cnblogs.com/catch/p/3857964.html
设置环境变量:export PATH=你编译的路径:$PATH
(1)makefile规范:
目标(必存在):依赖(可选)
指令(必存在)
(2)
$@:替换目标
$^:替换依赖(如果依赖存在)
$<:第一个依赖文件
/**
指定包含的库路经、库名称、头文件,
缺点:不能把%.o输出到obj文件夹内,后期再修改
**/
CC = aarch64-linux-gnu-g++
CFLAGS = -W -Wall -Wshadow -g
ROOT_DIR = $(shell pwd)
LIB_DIR=$(ROOT_DIR)/lib
BIN_DIR=$(ROOT_DIR)/bin
SRC_DIR=$(ROOT_DIR)/src
OBJ_DIR=$(ROOT_DIR)/obj
LIB_PATH = -L/home/wcg/VisionSDK_S32V2_RTM_1_3_0/s32v234_sdk/3rdparty/ocv/linux-arm64/lib
LIB_PATH += -L/home/wcg/VisionSDK_S32V2_RTM_1_3_0/s32v234_sdk/3rdparty/ffmpeg/linux-arm64/lib
LIB = -lrt -lavcodec -lavformat -lavutil -lswscale -lswresample -lopencv_core -lopencv_highgui \
-lopencv_imgproc -lopencv_imgcodecs -lopencv_videoio -lopencv_objdetect -lopencv_ml
INC_DIR = -I${SRC_DIR}/face_detect \
-I${SRC_DIR}/image_ar0144_process \
-I${SRC_DIR}/gview_v4l2core \
-I./include
INC_DIR += -I/home/wcg/VisionSDK_S32V2_RTM_1_3_0/s32v234_sdk/3rdparty/ocv/linux-arm64/include/
OBJ_LIST = $(patsubst %.cpp,%.o,$(wildcard ${SRC_DIR}/face_detect/*.cpp))
OBJ_LIST += $(patsubst %.cpp,%.o,$(wildcard ${SRC_DIR}/image_ar0144_process/*.cpp))
OBJ_LIST += $(patsubst %.c,%.o,$(wildcard ${SRC_DIR}/gview_v4l2core/*.c))
TARGET = face_detect
BIN_TARGET = ${BIN_DIR}/${TARGET}
$(BIN_TARGET):${OBJ_LIST}
$(CC) $^ -o $@ $(LIB_PATH) ${LIB}
%.o:%.cpp
$(CC) $(CFLAGS) -c $< -o $@ $(INC_DIR)
%.o:%.c
$(CC) $(CFLAGS) -c $< -o $@ $(INC_DIR)
obj_list:
@echo ${OBJ_LIST}
src:
@echo ${SRC}
clean:
rm -rf $(OBJ_LIST) ${BIN_TARGET}
标签:SRC,%.,lopencv,LIB,Makefile,笔记,OBJ,DIR 来源: https://blog.csdn.net/m0_37092540/article/details/86489418