# 编译器 CXX = g++ # 编译选项 CXXFLAGS = -std=c++11 -Wall # OpenCV 库路径和链接库 OPENCV_LIBS = -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_imgcodecs -lopencv_highgui -lopencv_ml OPENCV_CFLAGS = -I/usr/local/include/opencv4 # 目标可执行文件 TARGET = main # 源文件 SRCS = src/main.cpp # 目标文件 OBJS = $(SRCS:.cpp=.o) # 默认目标 all: $(TARGET) # 生成可执行文件 $(TARGET): $(OBJS) $(CXX) $(CXXFLAGS) -o $(TARGET) $(OBJS) $(OPENCV_LIBS) # 生成目标文件 %.o: %.cpp $(CXX) $(CXXFLAGS) $(OPENCV_CFLAGS) -c $< -o $@ # 清理生成的文件 clean: rm -f $(OBJS) $(TARGET) .PHONY: all clean