jupp0r / prometheus-cpp

Prometheus Client Library for Modern C++
Other
924 stars 326 forks source link

build failed with bazel #118

Closed mysjz-qingquanshishangliu closed 6 years ago

mysjz-qingquanshishangliu commented 6 years ago

I got one example via git clone https://github.com/bazelbuild/examples/, then build the example successfully with bazel.

According to the reference of https://github.com/jupp0r/prometheus-cpp, I made below update for the example. but failed to build, anyone can help to check it or any advices. Thanks.

1. update the hello-world.cc with below content.

include

include

include

include

include

include <prometheus/exposer.h>

include <prometheus/registry.h>

int main(int argc, char** argv) { using namespace prometheus;

// create an http server running on port 8080 Exposer exposer{"127.0.0.1:8080"};

// create a metrics registry with component=main labels applied to all its // metrics auto registry = std::make_shared();

// add a new counter family to the registry (families combine values with the // same name, but distinct label dimenstions) auto& counter_family = BuildCounter() .Name("time_running_seconds") .Help("How many seconds is this server running?") .Labels({{"label", "value"}}) .Register(*registry);

// add a counter to the metric family auto& second_counter = counter_family.Add( {{"another_label", "value"}, {"yet_another_label", "value"}});

// ask the exposer to scrape the registry on incoming scrapes exposer.RegisterCollectable(registry);

for (;;) { std::this_thread::sleep_for(std::chrono::seconds(1)); // increment the counter by one (second) second_counter.Increment(); } return 0; }

2. add the following to WORKSPACE: http_archive( name = "com_github_jupp0r_prometheus_cpp", strip_prefix = "prometheus-cpp-master", urls = ["https://github.com/jupp0r/prometheus-cpp/archive/master.zip"], )

load("@com_github_jupp0r_prometheus_cpp//:repositories.bzl", "prometheus_cpp_repositories")

prometheus_cpp_repositories()

3. reference this library in BUILD file cc_binary( name = "hello-world", srcs = ["hello-world.cc"], deps = ["@com_github_jupp0r_prometheus_cpp//:prometheus_cpp"], )

Then build with command "d:\bazel\bazel build //main:hello-world" got errors as below: D:\exporter\examples\cpp-tutorial\stage1>d:\bazel\bazel build //main:hello-world Starting local Bazel server and connecting to it... ......................... Loading: Loading: 0 packages loaded Analyzing: target //main:hello-world (2 packages loaded) Analyzing: target //main:hello-world (7 packages loaded) INFO: Analysed target //main:hello-world (9 packages loaded). INFO: Found 1 target... Building: no action [1 / 8] [-----] BazelWorkspaceStatusAction stable-status.txt [27 / 43] Compiling external/civetweb/src/civetweb.c; 0s local ... (3 actions running) [27 / 43] Compiling external/civetweb/src/civetweb.c; 2s local ... (4 actions running) ERROR: C:/users/willl/_bazel_willl/6tqwvxjt/external/civetweb/BUILD.bazel:13:1: undeclared inclusion(s) in rule '@civetweb//:libcivetweb': this rule is missing dependency declarations for the following files included by 'external/civetweb/src/civetweb.c': 'external/civetweb/src/file_ops.inl' Target //main:hello-world failed to build Use --verbose_failures to see the command lines of failed build steps. INFO: Elapsed time: 15.034s, Critical Path: 3.38s INFO: 2 processes: 2 local. FAILED: Build did NOT complete successfully FAILED: Build did NOT complete successfully

D:\exporter\examples\cpp-tutorial\stage1>

BTW, I git clone https://github.com/jupp0r/prometheus-cpp.git, and bazel build //:prometheus_cpp Got the same errors. D:\example\prometheus-cpp>d:\bazel\bazel build //:prometheus_cpp Starting local Bazel server and connecting to it... ......................... Loading: Loading: 0 packages loaded Analyzing: target //:prometheus_cpp (2 packages loaded) Analyzing: target //:prometheus_cpp (8 packages loaded) INFO: Analysed target //:prometheus_cpp (8 packages loaded). INFO: Found 1 target... Building: no action [0 / 6] [-----] BazelWorkspaceStatusAction stable-status.txt [21 / 32] Compiling lib/gauge.cc; 1s local ... (4 actions running) [24 / 32] Compiling lib/summary.cc; 2s local ... (2 actions running) [28 / 32] Compiling lib/check_names.cc; 1s local ... (3 actions running) ERROR: C:/users/willl/_bazel_willl/c3vtfeq2/external/civetweb/BUILD.bazel:13:1: undeclared inclusion(s) in rule '@civetweb//:libcivetweb': this rule is missing dependency declarations for the following files included by 'external/civetweb/src/civetweb.c': 'external/civetweb/src/file_ops.inl' Target //:prometheus_cpp failed to build Use --verbose_failures to see the command lines of failed build steps. INFO: Elapsed time: 11.933s, Critical Path: 2.76s INFO: 5 processes: 5 local. FAILED: Build did NOT complete successfully FAILED: Build did NOT complete successfully

gjasny commented 6 years ago

I can reproduce that on a Windows 10 machine with Bazel 0.15.0 and VS2017 / 2013 installed. I'll take a look.

mysjz-qingquanshishangliu commented 6 years ago

my environment, windows 7 machine with bazel 0.15.0 and VS2015.