[英]Can bazel build dll?
I've tried to compile a DLL using bazel for days.我已经尝试使用 bazel 编译 DLL 好几天了。 I followed the example bazel build hoping to generate a DLL.我按照示例bazel build希望生成一个 DLL。 The BUILD file I used is as follow:我使用的BUILD文件如下:
cc_binary(
name = "expdtctlib",
srcs = ["expdtctlib.cpp"],
deps = [
"//tensorflow/core:tensorflow",
],
linkshared = 1,
)
cc_binary(
name = "expdetect",
srcs = ["expdetect.cpp"],
data = [":expdtctlib.dll"],
deps = [
"//tensorflow/core:tensorflow",
],
)
I ran the command :我运行了命令:
bazel build :expdetect
But an error said the "expdtctlib.dll" was missing.但是一个错误说“expdtctlib.dll”丢失了。 Don't bazel first generate "expdtctlib.dll" and then compile "expdetect.cpp"? bazel不是先生成“expdtctlib.dll”再编译“expdetect.cpp”吗?
Besides,I've tried to use a another way to build DLL.The BUILD file is as follow:此外,我尝试使用另一种方式来构建DLL。 BUILD 文件如下:
cc_library(
name = "ExpDetector",
srcs = ["ExpDetector.cc"],
hdrs = ["ExpDetector.h"],
deps = [
"//tensorflow/core:tensorflow",
],
)
cc_binary(
name = "expdetect",
srcs = ["expdetect.cc"],
deps = [
"//tensorflow/core:tensorflow",
":ExpDetector",
],
)
After a long time compiling,though a EXE file was output and ran well,I could only find .lib and .exp file but the .dll file.经过长时间的编译,虽然输出了一个EXE文件并且运行良好,但我只能找到.lib和.exp文件,而找不到.dll文件。
Is there anyone successfully build DLL using bazel?I need your help please.有没有人使用 bazel 成功构建 DLL?我需要你的帮助。
I modified two BUILD files as follow and it worked well!我修改了两个 BUILD 文件如下,效果很好!
filegroup(
name = "srcs",
srcs = glob(["**"]),
visibility = ["//examples:__pkg__"],
)
cc_binary(
name = "expdtctlib.dll",
srcs = ["expdtctlib.cc",
"expdtctlib.h"],
deps = [
"//tensorflow/core:tensorflow",
],
linkshared = 1,
)
cc_binary(
name = "expdetect",
srcs = ["expdetect.cc"],
data = [":expdtctlib.dll"],
deps = [
"//tensorflow/core:tensorflow",
],
)
The one below is in "//tensorflow".下面的一个在“//tensorflow”中。
exports_files(
[
"LICENSE",
"ACKNOWLEDGEMENTS",
],
)
package(default_visibility = ["//visibility:public"])
filegroup(
name = "srcs",
srcs = glob(["**"]) + [
"//tensorflow/tensorflow/detector0405:srcs",
],
)
I am not familiar with bazel and c++,but these modification work.I'll read Bazel Document to learn more.我对 bazel 和 c++ 不熟悉,但这些修改工作。我会阅读Bazel 文档以了解更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.