Makefile 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # 编译器和链接器设置
  2. CXX = g++
  3. CXXFLAGS = -std=gnu++11 -g -O0 -Wall -DLINUX -DACTION_SINGLETON -D__STDC_CONSTANT_MACROS -Wno-deprecated -Wno-write-strings \
  4. -I/usr/local/include/opencv4 \
  5. -I/usr/local/cuda-11.8/include \
  6. -I../../include \
  7. -I../../links/common/include \
  8. -I../../links/rapidjson/include \
  9. -I../../mascommon/include \
  10. -I../../detector/detdef/include \
  11. -I../../strategy/stradef/include \
  12. -I../../strategy/components/headcount/include \
  13. -I../../detector/components/yolocrowd/include \
  14. -I../../detector/components/deps/detutils/include \
  15. -I../../detector/components/deps/tensorRT_Pro/include/application \
  16. -I../../detector/components/deps/tensorRT_Pro/include/tensorrt
  17. LDFLAGS = -L../../mascommon/source/.libs \
  18. -L../../links/common/libs \
  19. -L../../detector/components/yolocrowd/source \
  20. -L../../detector/components/deps/detutils/source \
  21. -L../../detector/components/deps/tensorRT_Pro/source \
  22. -L../../strategy/components/headcount/source
  23. LIBS = -lcommon -lpthread -ldl -ltensorrtpro -ldetutils \
  24. -lopencv_core -lopencv_imgproc -lopencv_imgcodecs \
  25. -lyolocrowddetector -lheadcountstrategy
  26. # 目标文件和目标库设置
  27. TARGET = build/ImageDemo
  28. BUILD_DIR = build
  29. OBJECTS = $(BUILD_DIR)/ImageDemo.o $(BUILD_DIR)/StreamDef.o $(BUILD_DIR)/MemPool.o
  30. # 编译目标
  31. all: $(BUILD_DIR) $(TARGET)
  32. # 创建 build 目录
  33. $(BUILD_DIR):
  34. mkdir -p $(BUILD_DIR)
  35. # 链接最终的可执行文件
  36. $(TARGET): $(OBJECTS)
  37. $(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(LIBS)
  38. # 生成目标文件(.o)
  39. $(BUILD_DIR)/ImageDemo.o: ImageDemo.cpp
  40. $(CXX) $(CXXFLAGS) -o $@ -c $<
  41. # 编译 StreamDef.cpp 为目标文件
  42. $(BUILD_DIR)/StreamDef.o: ../../mascommon/source/StreamDef.cpp
  43. $(CXX) $(CXXFLAGS) -o $@ -c $<
  44. # 编译 MemPool.cpp 为目标文件
  45. $(BUILD_DIR)/MemPool.o: ../../mascommon/source/MemPool.cpp
  46. $(CXX) $(CXXFLAGS) -o $@ -c $<
  47. # 清理中间文件和目标文件
  48. clean:
  49. rm -rf $(BUILD_DIR)
  50. # 创建可执行文件时保留详细信息
  51. verbose:
  52. @echo "CXX: $(CXX)"
  53. @echo "CXXFLAGS: $(CXXFLAGS)"
  54. @echo "LDFLAGS: $(LDFLAGS)"
  55. @echo "LIBS: $(LIBS)"
  56. .PHONY: clean verbose