• makefile opencv的案例


     1 CXX = g++
     2 LIBS +=`pkg-config --libs opencv`
     3 INC +=`pkg-config --cflags opencv`
     4 CPPFLAGS += -g -std=c++11 -Wall
     5 
     6 SRCS = detect.cpp
     7 TARGET = detect
     8 OBJS = detect.o
     9 
    10 $(TARGET):$(OBJS)
    11     $(CXX) $(INC) $(CPPFLAGS) $(OBJS) -o $(TARGET) $(LIBS)
    12 $(OBJS):%.o:%.cpp
    13     $(CXX) $(INC) $(CPPFLAGS) -c $< -o $@
    14 
    15 .PHONY:clean
    16 clean:
    17     rm -r *.o $(TARGET)
     1 CXX = g++
     2 LDLIBS += `pkg-config --libs opencv`
     3 INC += `pkg-config --cflags opencv`
     4 CPPFLAGS += -g -std=c++11 -Wall -I./
     5 
     6 TARGET = edges
     7 OBJS = edges.o label.o
     8 SRCS = edges.cpp label.cpp
     9 HEAD = label.hpp
    10 
    11 $(TARGET):$(OBJS)
    12     $(CXX) -o $(TARGET) $(OBJS) $(LDLIBS)
    13 
    14 %.o:%.c $(HEAD)
    15     $(CXX) $(INC) $(CPPFLAGS) -c $> -o $@
    16 
    17 .PHONY:clean
    18 clean:
    19     rm -r *.o 
     1 CXX = g++
     2 INC += `pkg-config --cflags opencv`
     3 LIBS += `pkg-config --libs opencv`
     4 
     5 
     6 #dir
     7 DIR_INC = ./include
     8 DIR_SRC = ./src
     9 DIR_OBJ = ./obj
    10 DIR_BIN = ./bin
    11 
    12 CPPFLAGS += -g -std=c++11 -Wall -I${DIR_INC}
    13 
    14 #SRC = $(wildcard ${DIR_SRC}/*.cpp) 
    15 SRC1 = ${DIR_SRC}/detect.cpp ${DIR_SRC}/tools.cpp 
    16 OBJ1 = $(patsubst %.cpp,${DIR_OBJ}/%.o,$(notdir ${SRC1})) 
    17 BIN_TARGET1 = ${DIR_BIN}/detect
    18 
    19 SRC2 = ${DIR_SRC}/detect2.cpp ${DIR_SRC}/tools.cpp 
    20 OBJ2 = $(patsubst %.cpp,${DIR_OBJ}/%.o,$(notdir ${SRC2})) 
    21 BIN_TARGET2 = ${DIR_BIN}/detect2
    22 
    23 SRC3 = ${DIR_SRC}/detect_circle.cpp ${DIR_SRC}/tools.cpp 
    24 OBJ3 = $(patsubst %.cpp,${DIR_OBJ}/%.o,$(notdir ${SRC3})) 
    25 BIN_TARGET3 = ${DIR_BIN}/detect_circle
    26 
    27 SRC4 = ${DIR_SRC}/detect_circle2.cpp ${DIR_SRC}/tools.cpp 
    28 OBJ4 = $(patsubst %.cpp,${DIR_OBJ}/%.o,$(notdir ${SRC4})) 
    29 BIN_TARGET4 = ${DIR_BIN}/detect_circle2
    30 
    31 SRC5 = ${DIR_SRC}/hog_svm_test.cpp ${DIR_SRC}/tools.cpp 
    32 OBJ5 = $(patsubst %.cpp,${DIR_OBJ}/%.o,$(notdir ${SRC5})) 
    33 BIN_TARGET5 = ${DIR_BIN}/hog_svm_test
    34 
    35 SRC6 = ${DIR_SRC}/hog_svm_test2.cpp ${DIR_SRC}/tools.cpp 
    36 OBJ6 = $(patsubst %.cpp,${DIR_OBJ}/%.o,$(notdir ${SRC6})) 
    37 BIN_TARGET6 = ${DIR_BIN}/hog_svm_test2
    38 
    39 SRC7 = ${DIR_SRC}/hog_svm_test2.cpp ${DIR_SRC}/tools.cpp 
    40 OBJ7 = $(patsubst %.cpp,${DIR_OBJ}/%.o,$(notdir ${SRC7})) 
    41 BIN_TARGET7 = ${DIR_BIN}/hog_svm_test3
    42 
    43 detect:${BIN_TARGET1}
    44 
    45 detect2:${BIN_TARGET2}
    46 
    47 detect_circle:${BIN_TARGET3}
    48 
    49 detect_circle2:${BIN_TARGET4}
    50 
    51 hog_svm_test:${BIN_TARGET5}
    52 
    53 hog_svm_test2:${BIN_TARGET6}
    54 
    55 hog_svm_test3:${BIN_TARGET7}
    56 
    57 # echo:
    58 #     echo $(OBJ1)
    59 #     echo $(BIN_TARGET)
    60 #     echo $(notdir ${SRC1})
    61 
    62 ${BIN_TARGET1}:${OBJ1}
    63     $(CXX) -o $@  $(OBJ1)  $(LIBS)
    64 
    65 ${BIN_TARGET2}:${OBJ2}
    66     $(CXX) -o $@  $(OBJ2)  $(LIBS)
    67 
    68 ${BIN_TARGET3}:${OBJ3}
    69     $(CXX) -o $@  $(OBJ3)  $(LIBS)
    70 
    71 ${BIN_TARGET4}:${OBJ4}
    72     $(CXX) -o $@  $(OBJ4)  $(LIBS)
    73 
    74 ${BIN_TARGET5}:${OBJ5}
    75     $(CXX) -o $@  $(OBJ5)  $(LIBS)
    76 
    77 ${BIN_TARGET6}:${OBJ6}
    78     $(CXX) -o $@  $(OBJ6)  $(LIBS)
    79 
    80 ${BIN_TARGET7}:${OBJ7}
    81     $(CXX) -o $@  $(OBJ7)  $(LIBS)
    82    
    83 
    84 ${DIR_OBJ}/%.o:${DIR_SRC}/%.cpp
    85     $(CXX)  $(CPPFLAGS) -c  $< -o $@
    86 
    87 
    88 .PHONY:clean
    89 clean:
    90     find ${DIR_OBJ} -name *.o -exec rm -rf {} ;
     
     
  • 相关阅读:
    SecureCRT 安装及初始化配置
    企业生产环境中linux系统分区的几种方案
    Django之验证码 + session 认证
    Django之上传文件
    Django之Cookie与Session
    Django之CSRF 跨站请求伪造
    web前端之 DOM
    c++ 之 字符和字符串
    web前端
    调用线程无法访问此对象,因为另一个线程拥有该对象
  • 原文地址:https://www.cnblogs.com/buyizhiyou/p/10119721.html
Copyright © 2020-2023  润新知