0

I'm new to bazel and c++ development. I have a similar situation as posted in here and here. Followed the steps posted in the first link ,where I'm trying to load this locally built package into a bazel project.

WORKSPACE

new_local_repository(
    name = "openvino",
    build_file = "backend/cpp/BUILD",
    path = "C:\\Users\\user\\OpenVINO2022.1.0.dev20220316_OMP\\openvino",
)

BUILD file inside backend/cpp folder

cc_library(
    name = "openvino",
    srcs = glob(["**/*.lib"])+ glob(["**/*.dll"]),
    hdrs = glob(["**/*.hpp"]),
    includes = ["src/inference/include/openvino"],
    visibility = ["//visibility:public"]
)

cc_library(
    name = "main_c",
    srcs = ["main_c.cc"],
    hdrs = [
        "utils.h",
    ],
    deps = [
        "//flutter/cpp/c:headers",
    ],
    alwayslink = 1,
    visibility = ["//visibility:public"]
)

cc_binary(
    name = "libbackend.dll",
    linkshared = 1,
    win_def_file = "//flutter/cpp/c:dll_export.def",
    deps = [
        ":openvino",
        ":main_c",
    ],
     linkopts = ["-shared"],
)

main_c.cc file in backend/cpp folder

#include "openvino\src\inference\include\openvino\openvino.hpp"

But I'm still not able to load this library.

Error

backend/cpp/main_c.cc(7): fatal error C1083: Cannot open include file: 'openvino\src\inference\include\openvino\openvino.hpp': No such file or directory

Any help is appreciated.

Manasa
  • 21
  • 5
  • If you get this working I would appreciate a ping. I’ve tried it before and gave up and switched back to visual studio. – Taekahn Jul 15 '22 at 01:06
  • Can I know what you ment by " switched back to visual studio " ? were you able to build it with visual studio ? – Manasa Jul 15 '22 at 01:56
  • I abandoned bazel build (sadly) and went with visual studio for the project. Including a dll in a project with visual studio is incredibly easy. Using visual studio I was able to successfully build and run the project. For reference it was lippcap.dll I was trying to use. – Taekahn Jul 15 '22 at 01:57

1 Answers1

0

This seems to be an issue with your include paths. The include path to your header should be.

#include "src\inference\include\openvino\openvino.hpp"

Or as you've added includes = ["src/inference/include/openvino"] to your 'openvino' target you could also use the include path.

#include "openvino.hpp"

If for some reason you need to keep your include path the same you can add an include prefix to your 'openvino' target.

e.g.

cc_library(
    name = "openvino",
    srcs = glob(["**/*.lib"])+ glob(["**/*.dll"]),
    hdrs = glob(["**/*.hpp"]),
    # Remove this line.
    # includes = ["src/inference/include/openvino"],
    
    # Add this line, to allow include as if it were in an "openvino"
    # directory.
    include_prefix = "openvino",
    visibility = ["//visibility:public"]
)
silvergasp
  • 1,517
  • 12
  • 23