我正在尝试导入这些Header文件:
AffdexException.h Detector.h FaceListener.h Frame.h
PhotoDetector.h typedefs.h
CameraDetector.h Face.h FrameDetector.h ImageListener.h
ProcessStatusListener.h VideoDetector.h
它们位于/ root / affdex-sdk / include下。这是我的基本WORKSPACE文件的样子:
new_local_repository(
name = "Boost",
path = "/usr/local/lib/",
build_file = "/usr/local/lib/BUILD.boost",
)
new_local_repository(
name = "OpenCV",
path = "/usr/lib/x86_64-linux-gnu/",
build_file = "/usr/lib/x86_64-linux-gnu/BUILD.opencv",
)
new_local_repository(
name = "AffdexSDK",
path = "/root/affdex-sdk/",
build_file = "/root/affdex-sdk/BUILD.affectiva",
)
问题在于AffdexSDK头文件。这是我的BUILD.affectiva:
package(default_visibility = ["//visibility:public"])
cc_library(
name = "affdex-sdk",
srcs = glob(["**/*.so"]),
hdrs = glob(["**/*.h"]),
)
和我的主目标的BUILD文件我想变成二进制文件:
cc_binary(
name = "video-detector",
srcs = ["vidDetector.cpp", "include/VideoDetector.h"],
deps = ["@AffdexSDK//:affdex-sdk",
"@Boost//:boost",
"@OpenCV//:opencv",
],
includes = [":affdex-sdk/include/"],
)
我需要编译的主要源代码文件的声明:
#include <iostream>
#include <memory>
#include <chrono>
#include <fstream>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <boost/filesystem.hpp>
#include <boost/timer/timer.hpp>
#include <boost/program_options.hpp>
#include </root/affdex-sdk/include/VideoDetector.h>
#include </root/affdex-sdk/include/PhotoDetector.h>
#include </root/affdex-sdk/include/AffdexException.h>
#include "/root/sdk-samples/common/PlottingImageListener.hpp"
#include "/root/sdk-samples/common/StatusListener.hpp"
当我运行命令bazel build // affdex-sdk:video-detector --verbose_failures:
我收到此错误:
错误:/ root / affdex-sdk / BUILD:1:1:规则&#39; // affdex-sdk中未声明的包含:视频检测器&#39;: 此规则缺少&quot; affdex-sdk / vidDetector.cpp&#39;所包含的以下文件的依赖声明:
'/root/affdex-sdk/include/VideoDetector.h'
'/root/affdex-sdk/include/FrameDetector.h'
'/root/affdex-sdk/include/Detector.h'
'/root/affdex-sdk/include/typedefs.h'
'/root/affdex-sdk/include/ImageListener.h'
'/root/affdex-sdk/include/Face.h'
'/root/affdex-sdk/include/Frame.h'
'/root/affdex-sdk/include/FaceListener.h'
'/root/affdex-sdk/include/ProcessStatusListener.h'
'/root/affdex-sdk/include/AffdexException.h'
'/root/affdex-sdk/include/PhotoDetector.h'
'/root/sdk-samples/common/PlottingImageListener.hpp'
'/root/sdk-samples/common/StatusListener.hpp'
所以我不确定为什么不包括这些因为我在BUILD.affectiva中通过glob获取这些头文件。我在vidDetector.cpp的声明中使用了绝对路径,因为否则它不会获取它们。我不知道如何包含sdk-samples / common hpp文件,但我认为affdex-sdk中的其他头文件都是通过BUILD.affectiva中的glob包含的。请帮我。
答案 0 :(得分:0)
通常,如何调试此类问题的好方法是查看复制到沙箱中的内容。该主题有一个blog post。
现在针对您的特定问题,我认为您应该将includes
属性添加到@AffdexSDK//:affdex-sdk
规则并将其从:video-detector
中删除。然后,您应该能够引用相对于其包含目录的标题,例如#include <Detector.h>
。
您也可以使用 strip_include_prefix和include_prefix有权调整包含您偏好的路径。