【发布时间】:2021-08-04 09:04:53
【问题描述】:
我收到以下错误。我在使用 bazel 4.0 和 msys2 的 Windows 10 上。
C:/Users/katso/Documents/Github/KeirosPublic/bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/protoc.exe: error while loading shared libraries: ?: cannot open shared object file: No such file or directory
当我运行这个命令时
bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/protoc.exe --proto_path=bazel-out/x64_windows-fastbuild/bin/external/com_google_protobuf/_virtual_imports/timestamp_proto --java_out=bazel-out/x64_windows-fastbuild/bin/Security/Proto/validity_period_proto-speed-src.jar -ISecurity/Proto/validity_period.proto=Security/Proto/validity_period.proto -Igoogle/protobuf/timestamp.proto=bazel-out/x64_windows-fastbuild/bin/external/com_google_protobuf/_virtual_imports/timestamp_proto/google/protobuf/timestamp.proto --direct_dependencies google/protobuf/timestamp.proto:Security/Proto/validity_period.proto
重新创建它的简单方法如下
WORKSPACE
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# rules_cc defines rules for generating C++ code from Protocol Buffers.
http_archive(
name = "rules_cc",
sha256 = "35f2fb4ea0b3e61ad64a369de284e4fbbdcdba71836a5555abb5e194cf119509",
strip_prefix = "rules_cc-624b5d59dfb45672d4239422fa1e3de1822ee110",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_cc/archive/624b5d59dfb45672d4239422fa1e3de1822ee110.tar.gz",
"https://github.com/bazelbuild/rules_cc/archive/624b5d59dfb45672d4239422fa1e3de1822ee110.tar.gz",
],
)
# rules_java defines rules for generating Java code from Protocol Buffers.
http_archive(
name = "rules_java",
sha256 = "ccf00372878d141f7d5568cedc4c42ad4811ba367ea3e26bc7c43445bbc52895",
strip_prefix = "rules_java-d7bf804c8731edd232cb061cb2a9fe003a85d8ee",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_java/archive/d7bf804c8731edd232cb061cb2a9fe003a85d8ee.tar.gz",
"https://github.com/bazelbuild/rules_java/archive/d7bf804c8731edd232cb061cb2a9fe003a85d8ee.tar.gz",
],
)
# rules_proto defines abstract rules for building Protocol Buffers.
http_archive(
name = "rules_proto",
sha256 = "2490dca4f249b8a9a3ab07bd1ba6eca085aaf8e45a734af92aad0c42d9dc7aaf",
strip_prefix = "rules_proto-218ffa7dfa5408492dc86c01ee637614f8695c45",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/218ffa7dfa5408492dc86c01ee637614f8695c45.tar.gz",
"https://github.com/bazelbuild/rules_proto/archive/218ffa7dfa5408492dc86c01ee637614f8695c45.tar.gz",
],
)
load("@rules_cc//cc:repositories.bzl", "rules_cc_dependencies")
rules_cc_dependencies()
load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains")
rules_java_dependencies()
rules_java_toolchains()
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
rules_proto_dependencies()
rules_proto_toolchains()
BUILD
proto_library(
name = "my_proto",
srcs = ["my.proto"]
)
cc_proto_library(
name = "my_cc_proto",
deps = [":my_proto"]
)
my.proto
message MyProto {
int64 value = 1;
}
如果您运行此命令的某个版本,您将获得可以运行以重现此命令的命令。
bazel build :all --compiler=mingw-gcc --verbose_failures
如果您遗漏了任何其他可能有用的信息,请告诉我。这基本上破坏了 bazel 的 mingw 编译器。我不能使用普通的 MSVC,因为我的依赖项只能在 mingw 中构建。
我跑了ldd protoc.exe 并得到了
ntdll.dll => /c/Windows/SYSTEM32/ntdll.dll (0x7ffcfa410000)
KERNEL32.DLL => /c/Windows/System32/KERNEL32.DLL (0x7ffcf89f0000)
KERNELBASE.dll => /c/Windows/System32/KERNELBASE.dll (0x7ffcf7f70000)
msvcrt.dll => /c/Windows/System32/msvcrt.dll (0x7ffcf86e0000)
这毫无意义,因为我的PATH 是/usr/local/bin:/usr/bin:/bin:/opt/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:C:/Users/katso/Documents/Github/KeirosPublic/bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/:/c/Users/katso/AppData/Local/Microsoft/WindowsApps:/c/Users/katso/Documents/Github/KeirosPublic/bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/:/c/Windows/SYSTEM32
【问题讨论】:
标签: c++ windows protocol-buffers bazel