Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors building -DWITH_JAEGER on Windows - Thrift missing #874

Closed
ghost opened this issue Jun 23, 2021 · 16 comments · Fixed by #913
Closed

Errors building -DWITH_JAEGER on Windows - Thrift missing #874

ghost opened this issue Jun 23, 2021 · 16 comments · Fixed by #913
Assignees
Labels
bug Something isn't working

Comments

@ghost
Copy link

ghost commented Jun 23, 2021

Describe your environment
Windows building with VS 2019 64 bit. Will also want to build Win32.

Steps to reproduce
Add the -DWITH_JAEGER flag to CMake on Windows to a build that was working without the flag set.

What is the expected behavior?
Clean build

Hopefully I am just missing a flag.

What is the actual behavior?

CMake complains that it can't find Thrift.

Set directory to c:\dev\AA3rdPartyExt\Build\opentelemetry-cpp\VS16\Win64
Invoking cmake to create the project files
Arguments = -A "x64" "c:\dev\AA3rdPartyExt\opentelemetry-cpp" "-DCMAKE_TOOLCHAIN_FILE=C:\dev\vcpkg\scripts\buildsystems\vcpkg.cmake" "-DCMAKE_PREFIX_PATH=c:\dev\AA3rdPartyExt\Build\Ninja\VS16\Win64;c:\dev\AA3rdPartyExt\Build\nlohmann_json\VS16\Win64" -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DWITH_JAEGER=ON -DWITH_PROMETHEUS=OFF -DBUILD_TESTING=OFF -DJSON_Install=ON
Executing 'cmake' with arguments '-A "x64" "c:\dev\AA3rdPartyExt\opentelemetry-cpp" "-DCMAKE_TOOLCHAIN_FILE=C:\dev\vcpkg\scripts\buildsystems\vcpkg.cmake" "-DCMAKE_PREFIX_PATH=c:\dev\AA3rdPartyExt\Build\Ninja\VS16\Win64;c:\dev\AA3rdPartyExt\Build\nlohmann_json\VS16\Win64" -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DWITH_JAEGER=ON -DWITH_PROMETHEUS=OFF -DBUILD_TESTING=OFF -DJSON_Install=ON' in working directory 'c:\dev\AA3rdPartyExt\Build\opentelemetry-cpp\VS16\Win64'
Exit code: 1
Command error: Using external nlohmann::json
Building with nostd types...
CMake Error at C:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake:263 (_find_package):
asked CMake to find a package configuration file provided by "Thrift", but
By not providing "FindThrift.cmake" in CMAKE_MODULE_PATH this project has
CMake did not find one.
Could not find a package configuration file provided by "Thrift" with any
of the following names:
ThriftConfig.cmake
thrift-config.cmake
Add the installation prefix of "Thrift" to CMAKE_PREFIX_PATH or set
"Thrift_DIR" to a directory containing one of the above files. If "Thrift"
provides a separate development package or SDK, be sure it has been
installed.
Call Stack (most recent call first):
exporters/jaeger/CMakeLists.txt:3 (find_package)
Output: -- Building for architecture ARCH=x64
-- Could NOT find CURL (missing: CURL_LIBRARY CURL_INCLUDE_DIR)
-- Configuring incomplete, errors occurred!

Additional context
I tried installing Thrift from GitHub and using CMake, but it then complained that FLEX wasn't installed. All comments I found on this assume Linux. I quit digging at that point.

It would be preferable if the chained dependencies were automatically pulled in.

@ghost ghost added the bug Something isn't working label Jun 23, 2021
@lalitb
Copy link
Member

lalitb commented Jun 24, 2021

Thanks for trying it out, and reporting the issue. cc @ThomsonTan

@ThomsonTan
Copy link
Contributor

@Kurt-Rayner-Alpha could you please try install thrift via vcpkg as you are using it? Like c:\dev\vcpkg\vcpkg install thrift:x64-windows?

@maxgolov
Copy link
Contributor

maxgolov commented Jun 24, 2021

Unfortunately we do not have a snapshot of Thrift in submodules. While for nlohmann::json we could use our local submodule, we can't do that for Thrift. This script sets up the necessary dependencies. You may need to borrow the same / similar logic:

vcpkg install gtest:%ARCH%-windows

set ARCH=x64
vcpkg install gtest:%ARCH%-windows
vcpkg install --overlay-ports=%~dp0ports benchmark:%ARCH%-windows
vcpkg install --overlay-ports=%~dp0ports protobuf:%ARCH%-windows
vcpkg install ms-gsl:%ARCH%-windows
vcpkg install nlohmann-json:%ARCH%-windows
vcpkg install abseil:%ARCH%-windows
vcpkg install gRPC:%ARCH%-windows
vcpkg install prometheus-cpp:%ARCH%-windows
vcpkg install curl:%ARCH%-windows
vcpkg install thrift:%ARCH%-windows

vcpkg , perhaps, the easiest way to handle CMake dependencies on Windows.

@maxgolov
Copy link
Contributor

maxgolov commented Jun 24, 2021

I think we need to cover this as follows.

There are two documents presently available that describe the build process options:

  • Building with vcpkg - for this one we should modify the response file to add dependencies on all packages listed in my previous comment. While it lists some dependencies, I think thrift was added recently and is missing in that document.

  • Building with vs2019 - command line build process includes a reference to tools\setup-buildtols.cmd , which uses our local snapshot of vcpkg to build vcpkg first, then install all deps via vcpkg.

Maybe we need to add a separate document for raw CMake ? That, again - is mostly a "disclaimer-level" document about what components should be somehow manually installed before building OpenTelemetry C++ SDK. My personal preference would be, of course, to endorse the usage of vcpkg for package deps. Since building things like gRPC , thrift, etc. is a daunting task - in most cases that task should be outsourced to vcpkg build recipe.

@ghost
Copy link
Author

ghost commented Jun 25, 2021 via email

@maxgolov
Copy link
Contributor

@Kurt-Rayner-Alpha

We stay away from the “integrate” command line option

I totally agree with you on that. That is my experience as well. We don't use vcpkg integrate in OpenTelemetry. Instead we rely on the following:

  • local snapshot of vcpkg under the tools\vcpkg directory

  • we do respect VCPKG_ROOT environment variable, so if you want to use your own vcpkg, say at C:\vcpkg\, you can do so by setting environment variable set VCPKG_ROOT=C:\vcpkg\ then triggering the build. It should work fine. This is handled in the top-level CMakeListst.txt here:

    if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)

What I think we may be able to handle a bit better, is the implementation of the call to install_windows_deps in CMake. We verify for the presence of certain dependencies, and if they are not available - we call into install_windows_deps. I think we only do that for protobuf , gRPC and GTest. Not for thrift. I think we can add a few lines of code to perform the auto-installation of thrift the same way. This still relies on vcpkg (that we include internally), but would be a bit less of a hassle. Customers would no longer need to cover that part themselves. @ThomsonTan - we need to do the same as what we do here, but for thrift under WITH_JAEGER :

install_windows_deps()

@ThomsonTan
Copy link
Contributor

@maxgolov do you mean the below line? Thrift should be covered by install_windows_deps already in vcpkg.

vcpkg install thrift:%ARCH%-windows

@maxgolov
Copy link
Contributor

@ThomsonTan - it's covered if our customers runs setup-buildtools.cmd first. So, technically, it is covered...

But if someone did not run it - we could have invoked the install_windows_deps to install it, the way we handle WITH_OTLP case - pretty much the same way we do it for gRPC and protobuf.

Pseudocode:

if (WITH_JAGER)
  find_package(thrift QUIET)
  if (not_found_thrift) and (WIN32)
     install_windows_deps() // <- install it from our local vcpkg installation
     find_package(thrift REQUIRED)
  endif()
endif()

I'm thinking just Windows now, but the same concept could have been applied to other platforms - forcing the installation of deps if not installed. Going even further with FetchContent_xxxx instead of vcpkg - is probably an overkill, given all deps, etc. plus FetchContent requires a fairly fresh version of CMake.

@ghost
Copy link
Author

ghost commented Jun 25, 2021 via email

@ThomsonTan
Copy link
Contributor

@maxgolov we have this check and try to invoke install_windows_deps if the user is not passing in a separate vcpkg, which means the use is relying on our submodule vcpkg (see below link). If the user provides a standalone vcpkg, the user would be responsible to install all the dependencies via vcpkg install, including gRPC, thrift, etc. Perhaps we could provide some hint in the error output.

install_windows_deps()

@maxgolov
Copy link
Contributor

@ThomsonTan - Yes. You are right. I think what happened in Kurt's case, he supplied CMAKE_TOOLCHAIN_FILE and that is why we did not run the install_windows_deps , thus the issue with Thrift missing.

@ghost
Copy link
Author

ghost commented Jun 25, 2021 via email

@maxgolov
Copy link
Contributor

maxgolov commented Jun 29, 2021

Maybe we can improve it to try installing from our local vcpkg even if CMAKE_TOOLCHAIN_FILE is defined:

if(WITH_JAEGER)
  find_package(Thrift QUIET CONFIG)
  if(NOT Thrift_FOUND)
    # Install Thrift and propagate via vcpkg toolchain file
    if(WIN32)
      install_windows_deps()
    endif()
  endif()
endif()

However, I have a knowledge gap here. Not sure if we can combine the deps from two different locations - customer-supplied CMAKE_TOOLCHAIN_FILE , plus transitively adding ${CMAKE_CURRENT_SOURCE_DIR}/tools/vcpkg/scripts/buildsystems/vcpkg.cmake in addition to that... this is a bit interesting.

If we can't combine the two, then I think the best outcome is clearly document the prerequisites.

@lalitb
Copy link
Member

lalitb commented Jun 30, 2021

If we can't combine the two, then I think the best outcome is clearly document the prerequisites.

I would vote for documenting this. If CMAKE_TOOLCHAIN_FILE is supplied, the customer needs to ensure all dependencies are met (gRPC, thrift, and others) through it or separately.

@maxgolov
Copy link
Contributor

Yeah, I think we should update the documentation. The "default" process with setup-buildtools.cmd and vcpkg is already taking care of the necessary dependencies.

@ThomsonTan
Copy link
Contributor

Yes, agree that we should update the document on this. Also we could provide better error message to detect the dependency is missing for the customer provided vcpkg, and prompt the resolution accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants