我正在尝试导入这些头文件:

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:未在规则“// affdex-sdk:video-detector”中包含:
对于“affdex-sdk / vidDetector.cpp”包含的以下文件,此规则缺少依赖项声明:
 '/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包含的。请帮我。

最佳答案

通常,调试此类问题的好方法是查看复制到沙箱中的内容。关于这个主题有一个blog post

现在到您的特定问题,我认为您应该将includes属性置于@AffdexSDK//:affdex-sdk规则中,并将其从:video-detector中删除。然后,您应该能够引用相对于其包含目录的 header ,例如#include <Detector.h>

您也可以使用
strip_include_prefixinclude_prefix属性可根据您的喜好调整包含路径。

09-10 09:37
查看更多