我的QT项目中有以下文件夹hieararchy,我需要在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类中包含Utilities中的类时:
#include "Utilities/className.h"
编译器总是失败..不确定为什么?似乎有些事情被错过或误解了。
感谢。
答案 0 :(得分:2)
您的行include_directories(../Utilities)
会添加路径../Utilities
以包含目录。但是,您在源文件中包含Utilities/className.h
,使编译器搜索文件./Utilities/className.h
和../Utilities/Utilities/className.h
。
删除Utilities
或include_directories
中的#include
之一。
include_directories(..)
或
#include "className.h"