使用 Bazel 构建 dlib C++ 代码
Building dlib C++ code using Bazel
使用 Bazel 构建使用 dlib 库的 C++ 代码的最佳方法是什么?即,BUILD 规则会是什么样子?
我尝试按照 进行如下操作,但没有成功:
cc_library(
name = "dlib",
srcs = glob(["build/dlib/*.so*"]),
hdrs = glob(["dlib/*.h"]),
includes = ["include"],
visibility = ["//visibility:public"],
linkstatic = 1,
)
我想我明白了。假设 dlib 被解压缩到 /opt/dlib-19.2 并内置于 /opt/dlib-19.2/build.
在您的 WORKSPACE 文件中:
new_local_repository(
name = "dlib",
path = "/opt/dlib-19.2",
build_file = "dlib.BUILD",
)
在dlib.BUILD中:
cc_library(
name = "dlib",
srcs = glob(["build/dlib/*.so*"]),
hdrs = glob(["dlib/**/*.h"]),
includes = ["."],
visibility = ["//visibility:public"],
linkstatic = 1,
)
使用 Bazel 构建使用 dlib 库的 C++ 代码的最佳方法是什么?即,BUILD 规则会是什么样子?
我尝试按照
cc_library(
name = "dlib",
srcs = glob(["build/dlib/*.so*"]),
hdrs = glob(["dlib/*.h"]),
includes = ["include"],
visibility = ["//visibility:public"],
linkstatic = 1,
)
我想我明白了。假设 dlib 被解压缩到 /opt/dlib-19.2 并内置于 /opt/dlib-19.2/build.
在您的 WORKSPACE 文件中:
new_local_repository(
name = "dlib",
path = "/opt/dlib-19.2",
build_file = "dlib.BUILD",
)
在dlib.BUILD中:
cc_library(
name = "dlib",
srcs = glob(["build/dlib/*.so*"]),
hdrs = glob(["dlib/**/*.h"]),
includes = ["."],
visibility = ["//visibility:public"],
linkstatic = 1,
)