jupp0r / prometheus-cpp

Prometheus Client Library for Modern C++
Other
939 stars 330 forks source link

Build on Windows Fails with Missing Libs #136

Closed jmin911 closed 6 years ago

jmin911 commented 6 years ago

Windows build has errors indicating that Google Benchmark library is needed. Also is CURL needed?

-- Could NOT find GoogleBenchmark (missing: GoogleBenchmark_LIBRARY GoogleBenchmark_INCLUDE_DIR) CMake Error at C:/Program Files/CMake/share/cmake-3.12/Modules/FindPackageHandleStandardArgs.cmake:137 (message): Could NOT find CURL (missing: CURL_LIBRARY CURL_INCLUDE_DIR)

gjasny commented 6 years ago

Sorry, Windows is not our most loved target platform. There's an open ticket to add prometheus-cpp to vcpkg: #130. If you need the missing functionality (or convenience) maybe you can take a look?

Google Benchmark is an optional dependency used only for benchmarks that are used by prometheus-cpp developers. It is not part of any library and usually end users should not need those. So just ignore the message.

The curl dependency is solely used for the Push Gateway support. If you don't run short-lived micro services the prometheus pull exposer might better serve your needs. Just disable the push library by setting the ENABLE_PUSH=OFF CMake option. If the option is not enabled, the curl lookup will be omitted.

jupp0r commented 6 years ago

Even short lived microservices are well supported to be dynamically added/removed from your config if you are using one of the service discovery mechanisms (Azure/AWS/GCE/Kubernetes/Consul/Mesos/...) described in https://prometheus.io/docs/prometheus/latest/configuration/configuration/. You really shouldn't use the push gateway except in some edge cases (mainly a NAT being between your services and prometheus, but why would you ... ). See https://prometheus.io/docs/practices/pushing/ for details.

jmin911 commented 6 years ago

If push is not recommended, should it be disabled by default? option(ENABLE_PUSH "Build prometheus-cpp push library" OFF)

mathijs727 commented 6 years ago

There is a bug in cmake/cpr-config.cmake on line 50: target_include_directories(cpr PUBLIC ${CPR_INCLUDE_DIR}) This should also include the curl header file libraries: target_include_directories(cpr PUBLIC ${CPR_INCLUDE_DIR} ${CURL_INCLUDE_DIR}) Without this, the build will only succeed if the curl header files are in the system include directory (/usr/local/include on Linux IIRC) instead of using the include directory found by CMake's find_package.

With this change I was able to install and run the prometheus-cpp demo on my Windows machine (curl was installed through vcpkg). Google Benchmark is not required, ignore the error if you are not interested in building the benchmarks.

vyacheslav-skvortsov commented 6 years ago

Now it demands ZLIB: Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR) Call Stack (most recent call first): C:/Program Files/CMake/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE) C:/Program Files/CMake/share/cmake-3.13/Modules/FindZLIB.cmake:114 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) pull/CMakeLists.txt:10 (find_package) I tried setting ENABLE_PUSH=OFF but it did not help.

When I set ENABLE_COMPRESSION=OFF Could NOT find CURL (missing: CURL_LIBRARY) (found version "7.60.0") Call Stack (most recent call first): C:/Program Files/CMake/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE) C:/Program Files/CMake/share/cmake-3.13/Modules/FindCURL.cmake:74 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) push/CMakeLists.txt:2 (find_package) When I set ENABLE_COMPRESSION=OFF and ENABLE_PUSH=OFF generating was successful.

gjasny commented 6 years ago

Once #130 is resolved it will provide a convenient way to install prometheus-cpp on Windows.