我的QT项目中具有以下文件夹层次结构,并且需要在ImageProcessing文件夹的类中使用Utility文件夹的某些类。
实用程序的CMAKE文件:
file(GLOB Utilities_Files *.cpp *.h *.hpp)
# add component
add_library(Utilities ${Utilities_Files})
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
target_link_libraries(Utilities ${OpenCV_LIBRARIES})
ImageProcessing的CMAKE文件:
file(GLOB ImageProcessing_FILES *.cpp *.h *.hpp)
# add component
add_library(ImageProcessing ${ImageProcessing_FILES})
include_directories(../Utilities)
target_link_libraries(ImageProcessing Utilities)
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
target_link_libraries(ImageProcessing ${OpenCV_LIBRARIES})
当我尝试将实用程序中的类包含在ImageProcessing类中时:
#include "Utilities/className.h"
编译器总是失败。。不确定为什么吗?似乎有些遗漏或误解了。
谢谢。
最佳答案
您的行include_directories(../Utilities)
添加路径../Utilities
以包括目录。但是,您在源文件中包含Utilities/className.h
,这使编译器可以搜索文件./Utilities/className.h
和../Utilities/Utilities/className.h
。
删除Utilities
或include_directories
中的#include
之一。
include_directories(..)
要么
#include "className.h"