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

undefined reference to `opentelemetry::v1::sdk::common #1359

Closed
ccoqueiro opened this issue Apr 28, 2022 · 19 comments
Closed

undefined reference to `opentelemetry::v1::sdk::common #1359

ccoqueiro opened this issue Apr 28, 2022 · 19 comments
Labels
help wanted Good for taking. Extra help will be provided by maintainers

Comments

@ccoqueiro
Copy link

Hi Everyone,

A few days ago I'm trying to compile a simple hello world application(cpp), after the saga of the compilation of opentelemetry cpp SDK, I'm having the following error when running make:

/usr/bin/ld: /opt/otelcpp/lib/libopentelemetry_trace.a(random_id_generator.cc.o): in function opentelemetry::v1::sdk::trace::RandomIdGenerator::GenerateSpanId()': random_id_generator.cc:(.text+0x41): undefined reference to opentelemetry::v1::sdk::common::Random::GenerateRandomBuffer(opentelemetry::v1::nostd::span<unsigned char, 18446744073709551615ul>)'
/usr/bin/ld: /opt/otelcpp/lib/libopentelemetry_trace.a(random_id_generator.cc.o): in function opentelemetry::v1::sdk::trace::RandomIdGenerator::GenerateTraceId()': random_id_generator.cc:(.text+0xc7): undefined reference to opentelemetry::v1::sdk::common::Random::GenerateRandomBuffer(opentelemetry::v1::nostd::span<unsigned char, 18446744073709551615ul>)'
/usr/bin/ld: /opt/otelcpp/lib/libopentelemetry_exporter_jaeger_trace.a(THttpTransport.cc.o): in function opentelemetry::v1::exporter::jaeger::THttpTransport::THttpTransport(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::multimap<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, opentelemetry::v1::ext::http::client::cmp_ic, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >)': THttpTransport.cc:(.text+0xb6): undefined reference to opentelemetry::v1::ext::http::client::HttpClientFactory::CreateSync()'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/hello-otel.dir/build.make:113: hello-otel] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/hello-otel.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

My CMakeList.txt:

cmake_minimum_required(VERSION 3.23)
project(otel-test)

find_package(Protobuf REQUIRED)
find_package(nlohmann_json REQUIRED)
find_package(CURL REQUIRED)
find_package(gRPC REQUIRED)
find_package(Thrift REQUIRED)
find_package(absl REQUIRED)
find_package(opentelemetry-cpp CONFIG REQUIRED)

message(STATUS "otel c++ include dirs: ${OPENTELEMETRY_CPP_INCLUDE_DIRS}")
message(STATUS "otel c++ libs: ${OPENTELEMETRY_CPP_LIBRARIES}")
message(STATUS "thrift libs: ${THRIFT_FOUND_LIB}")

add_library(libopentelemetry_common STATIC IMPORTED)
add_library(libopentelemetry_resources STATIC IMPORTED)
add_library(libopentelemetry_trace STATIC IMPORTED)
add_library(libopentelemetry_version STATIC IMPORTED)
add_library(libopentelemetry_metrics STATIC IMPORTED)
add_library(libopentelemetry_http_client_curl STATIC IMPORTED)
add_library(lib_client_nosend STATIC IMPORTED)
add_library(libopentelemetry_otlp_recordable STATIC IMPORTED)
add_library(libopentelemetry_exporter_otlp_grpc_log STATIC IMPORTED)
add_library(libopentelemetry_exporter_otlp_http_client STATIC IMPORTED)
add_library(libopentelemetry_exporter_otlp_http STATIC IMPORTED)
add_library(libopentelemetry_exporter_otlp_grpc STATIC IMPORTED)
add_library(libopentelemetry_exporter_ostream_span STATIC IMPORTED)
add_library(libopentelemetry_exporter_jaeger_trace STATIC IMPORTED)
add_library(libt STATIC IMPORTED)

set_target_properties(libt PROPERTIES
IMPORTED_LOCATION "/usr/local/lib/libthrift.a"
)
set_target_properties(libopentelemetry_common PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libopentelemetry_common.a"
)
set_target_properties(libopentelemetry_resources PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libopentelemetry_resources.a"
)
set_target_properties(libopentelemetry_trace PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libopentelemetry_trace.a"
)
set_target_properties(libopentelemetry_version PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libopentelemetry_version.a"
)
set_target_properties(libopentelemetry_metrics PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libopentelemetry_metrics.a"
)
set_target_properties(libopentelemetry_http_client_curl PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libopentelemetry_http_client_curl.a"
)
set_target_properties(lib_client_nosend PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libhttp_client_nosend.a"
)
set_target_properties(libopentelemetry_http_client_curl PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libopentelemetry_http_client_curl.a"
)
set_target_properties(lib_client_nosend PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libhttp_client_nosend.a"
)
set_target_properties(libopentelemetry_otlp_recordable PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libopentelemetry_otlp_recordable.a"
)
set_target_properties(libopentelemetry_exporter_otlp_grpc_log PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libopentelemetry_exporter_otlp_grpc_log.a"
)
set_target_properties(libopentelemetry_exporter_otlp_http_client PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libopentelemetry_exporter_otlp_http_client.a"
)
set_target_properties(libopentelemetry_exporter_otlp_http PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libopentelemetry_exporter_otlp_http.a"
)

set_target_properties(libopentelemetry_exporter_otlp_grpc PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libopentelemetry_exporter_otlp_grpc.a"
)
set_target_properties(libopentelemetry_exporter_ostream_span PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libopentelemetry_exporter_ostream_span.a"
)
set_target_properties(libopentelemetry_exporter_jaeger_trace PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libopentelemetry_exporter_jaeger_trace.a"
)

add_executable(hello-otel main.cpp)
target_include_directories(hello-otel PRIVATE ${OPENTELEMETRY_CPP_INCLUDE_DIRS})
target_link_libraries(hello-otel libopentelemetry_common libopentelemetry_resources libopentelemetry_trace
libopentelemetry_version libopentelemetry_metrics libopentelemetry_http_client_curl
lib_client_nosend libopentelemetry_otlp_recordable libopentelemetry_exporter_otlp_grpc_log
libopentelemetry_exporter_otlp_grpc_log libopentelemetry_exporter_otlp_http_client libopentelemetry_exporter_otlp_http
libopentelemetry_exporter_otlp_grpc libopentelemetry_exporter_ostream_span libopentelemetry_exporter_jaeger_trace
libt)

Command to build:

cmake -DCMAKE_PREFIX_PATH=/opt/otelcpp/ ..

Output of command to build:

cmake -DCMAKE_PREFIX_PATH=/opt/otelcpp/ ..
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Protobuf: /usr/local/lib/libprotobuf.so;-lpthread (found version "3.19.2")
-- Found nlohmann_json: /opt/otelcpp/lib/cmake/nlohmann_json/nlohmann_jsonConfig.cmake (found version "3.9.1")
-- Found CURL: /opt/vcpkg/installed/x64-linux/share/curl/CURLConfig.cmake (found version "7.82.0-DEV")
-- Found Threads: TRUE
-- Found thrift: /root/source/opentelemetry-cpp/tools/vcpkg
-- Found opentelemetry-cpp: /opt/otelcpp/include
-- otel c++ include dirs: /opt/otelcpp/include
-- otel c++ libs: opentelemetry-cpp::api;opentelemetry-cpp::sdk;opentelemetry-cpp::ext;opentelemetry-cpp::version;opentelemetry-cpp::common;opentelemetry-cpp::trace;opentelemetry-cpp::metrics;opentelemetry-cpp::in_memory_span_exporter;opentelemetry-cpp::otlp_recordable;opentelemetry-cpp::otlp_grpc_exporter;opentelemetry-cpp::otlp_http_client;opentelemetry-cpp::otlp_http_exporter;opentelemetry-cpp::ostream_span_exporter;opentelemetry-cpp::jaeger_trace_exporter;opentelemetry-cpp::http_client_curl
-- thrift libs:
-- Configuring done
-- Generating done
-- Build files have been written to: /opt/helloworld/build

Thank you in advance :-)

@ccoqueiro ccoqueiro added the bug Something isn't working label Apr 28, 2022
@owent
Copy link
Member

owent commented Apr 29, 2022

You should not create imported target yourself, please use target_link_libraries(hello-otel opentelemetry-cpp::ostream_span_exporter opentelemetry-cpp::jaeger_trace_exporter opentelemetry-cpp::otlp_grpc_exporter opentelemetry-cpp::otlp_grpc_log_exporter opentelemetry-cpp::otlp_http_exporter opentelemetry-cpp::sdk opentelemetry-cpp::logs opentelemetry-cpp::metrics opentelemetry-cpp::sdk) instead.

@owent owent added help wanted Good for taking. Extra help will be provided by maintainers and removed bug Something isn't working labels Apr 29, 2022
@lalitb
Copy link
Member

lalitb commented May 2, 2022

@ccoqueiro - Let us know if @owent suggestion fixes the issue, and good to close it.

@ccoqueiro
Copy link
Author

ccoqueiro commented May 3, 2022

Hello owent!!

Thank you for your suggestion. I set up as suggested, but returned a warning message when performing the build with cmake and returned an error while performing make.

cmake -DCMAKE_PREFIX_PATH=/opt/otelcpp/ ..
-- Found thrift: /root/source/opentelemetry-cpp/tools/vcpkg
-- otel c++ include dirs: /opt/otelcpp/include
-- otel c++ libs: opentelemetry-cpp::api;opentelemetry-cpp::sdk;opentelemetry-cpp::ext;opentelemetry-cpp::version;opentelemetry-cpp::common;opentelemetry-cpp::trace;opentelemetry-cpp::metrics;opentelemetry-cpp::in_memory_span_exporter;opentelemetry-cpp::otlp_recordable;opentelemetry-cpp::otlp_grpc_exporter;opentelemetry-cpp::otlp_http_client;opentelemetry-cpp::otlp_http_exporter;opentelemetry-cpp::ostream_span_exporter;opentelemetry-cpp::jaeger_trace_exporter;opentelemetry-cpp::http_client_curl
-- thrift libs:
-- Configuring done
CMake Warning (dev) in CMakeLists.txt:
Policy CMP0111 is not set: An imported target missing its location property
fails during generation. Run "cmake --help-policy CMP0111" for policy
details. Use the cmake_policy command to set the policy and suppress this
warning.

IMPORTED_LOCATION not set for imported target
"opentelemetry-cpp::ostream_span_exporter".
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) in CMakeLists.txt:
Policy CMP0111 is not set: An imported target missing its location property
fails during generation. Run "cmake --help-policy CMP0111" for policy
details. Use the cmake_policy command to set the policy and suppress this
warning.

IMPORTED_LOCATION not set for imported target
"opentelemetry-cpp::jaeger_trace_exporter".
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) in CMakeLists.txt:
Policy CMP0111 is not set: An imported target missing its location property
fails during generation. Run "cmake --help-policy CMP0111" for policy
details. Use the cmake_policy command to set the policy and suppress this
warning.

IMPORTED_LOCATION not set for imported target
"opentelemetry-cpp::otlp_grpc_exporter".
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) in CMakeLists.txt:
Policy CMP0111 is not set: An imported target missing its location property
fails during generation. Run "cmake --help-policy CMP0111" for policy
details. Use the cmake_policy command to set the policy and suppress this
warning.

IMPORTED_LOCATION not set for imported target
"opentelemetry-cpp::otlp_grpc_log_exporter".
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) in CMakeLists.txt:
Policy CMP0111 is not set: An imported target missing its location property
fails during generation. Run "cmake --help-policy CMP0111" for policy
details. Use the cmake_policy command to set the policy and suppress this
warning.

IMPORTED_LOCATION not set for imported target
"opentelemetry-cpp::otlp_http_exporter".
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) in CMakeLists.txt:
Policy CMP0111 is not set: An imported target missing its location property
fails during generation. Run "cmake --help-policy CMP0111" for policy
details. Use the cmake_policy command to set the policy and suppress this
warning.

IMPORTED_LOCATION not set for imported target "opentelemetry-cpp::metrics".
This warning is for project developers. Use -Wno-dev to suppress it.

-- Generating done
-- Build files have been written to: /opt/helloworld/build
root@LabC:/opt/helloworld/build# make
CMakeFiles/hello-otel.dir/build.make:95: *** target pattern contains no '%'. Stop.
make[1]: *** [CMakeFiles/Makefile2:82: CMakeFiles/hello-otel.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

My CMakeList.txt

cmake_minimum_required(VERSION 3.23)
project(otel-test)

find_package(Protobuf REQUIRED)
find_package(nlohmann_json REQUIRED)
find_package(CURL REQUIRED)
find_package(gRPC REQUIRED)
find_package(Thrift REQUIRED)
find_package(absl REQUIRED)
find_package(opentelemetry-cpp CONFIG REQUIRED)

message(STATUS "otel c++ include dirs: ${OPENTELEMETRY_CPP_INCLUDE_DIRS}")
message(STATUS "otel c++ libs: ${OPENTELEMETRY_CPP_LIBRARIES}")
message(STATUS "thrift libs: ${THRIFT_FOUND_LIB}")

add_library(libopentelemetry_proto STATIC IMPORTED)
add_library(libopentelemetry_common STATIC IMPORTED)
add_library(libopentelemetry_resources STATIC IMPORTED)
add_library(libopentelemetry_trace STATIC IMPORTED)
add_library(libopentelemetry_version STATIC IMPORTED)
add_library(libopentelemetry_metrics STATIC IMPORTED)
add_library(libopentelemetry_http_client_curl STATIC IMPORTED)
add_library(lib_client_nosend STATIC IMPORTED)
add_library(libopentelemetry_otlp_recordable STATIC IMPORTED)
add_library(libopentelemetry_exporter_otlp_grpc_log STATIC IMPORTED)
add_library(libopentelemetry_exporter_otlp_http_client STATIC IMPORTED)
add_library(libopentelemetry_exporter_otlp_http STATIC IMPORTED)
add_library(libopentelemetry_exporter_otlp_grpc STATIC IMPORTED)
add_library(libopentelemetry_exporter_ostream_span STATIC IMPORTED)
add_library(libopentelemetry_exporter_jaeger_trace STATIC IMPORTED)
add_library(libt STATIC IMPORTED)

set_target_properties(libt PROPERTIES
IMPORTED_LOCATION "/usr/local/lib/libthrift.a"
)
set_target_properties(libopentelemetry_proto PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libopentelemetry_proto.a"
)
set_target_properties(libopentelemetry_common PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libopentelemetry_common.a"
)
set_target_properties(libopentelemetry_resources PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libopentelemetry_resources.a"
)
set_target_properties(libopentelemetry_trace PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libopentelemetry_trace.a"
)
set_target_properties(libopentelemetry_version PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libopentelemetry_version.a"
)
set_target_properties(libopentelemetry_metrics PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libopentelemetry_metrics.a"
)
set_target_properties(libopentelemetry_http_client_curl PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libopentelemetry_http_client_curl.a"
)
set_target_properties(lib_client_nosend PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libhttp_client_nosend.a"
)
set_target_properties(libopentelemetry_otlp_recordable PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libopentelemetry_otlp_recordable.a"
)
set_target_properties(libopentelemetry_exporter_otlp_grpc_log PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libopentelemetry_exporter_otlp_grpc_log.a"
)
set_target_properties(libopentelemetry_exporter_otlp_http_client PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libopentelemetry_exporter_otlp_http_client.a"
)
set_target_properties(libopentelemetry_exporter_otlp_http PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libopentelemetry_exporter_otlp_http.a"
)
set_target_properties(libopentelemetry_exporter_otlp_grpc PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libopentelemetry_exporter_otlp_grpc.a"
)
set_target_properties(libopentelemetry_exporter_ostream_span PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libopentelemetry_exporter_ostream_span.a"
)
set_target_properties(libopentelemetry_exporter_jaeger_trace PROPERTIES
IMPORTED_LOCATION "/opt/otelcpp/lib/libopentelemetry_exporter_jaeger_trace.a"
)

add_executable(hello-otel main.cpp)

target_include_directories(hello-otel PRIVATE ${OPENTELEMETRY_CPP_INCLUDE_DIRS})
target_link_libraries(hello-otel opentelemetry-cpp::ostream_span_exporter opentelemetry-cpp::jaeger_trace_exporter opentelemetry-cpp::otlp_grpc_exporter opentelemetry-cpp::otlp_grpc_log_exporter opentelemetry-cpp::otlp_http_exporter opentelemetry-cpp::metrics opentelemetry-cpp::sdk)

@owent
Copy link
Member

owent commented May 3, 2022

@ccoqueiro target_include_directories(hello-otel PRIVATE ${OPENTELEMETRY_CPP_INCLUDE_DIRS}) and all IMPORTED targets can be removed.
Please try this CMakeLists.txt

cmake_minimum_required(VERSION 3.23)
project(otel-test)

find_package(Thrift REQUIRED)
find_package(opentelemetry-cpp CONFIG REQUIRED)

message(STATUS "otel c++ include dirs: ${OPENTELEMETRY_CPP_INCLUDE_DIRS}")
message(STATUS "otel c++ libs: ${OPENTELEMETRY_CPP_LIBRARIES}")
message(STATUS "thrift libs: ${THRIFT_FOUND_LIB}")

add_executable(hello-otel main.cpp)

target_link_libraries(hello-otel opentelemetry-cpp::ostream_span_exporter opentelemetry-cpp::jaeger_trace_exporter opentelemetry-cpp::otlp_grpc_exporter opentelemetry-cpp::otlp_grpc_log_exporter opentelemetry-cpp::otlp_http_exporter opentelemetry-cpp::metrics opentelemetry-cpp::sdk)

BTW: You can use cmake --build . to replace make for better compatibility.

@lalitb
Copy link
Member

lalitb commented May 6, 2022

@ccoqueiro - Just wondering if you still have issue after @owent suggestion above ?

@ccoqueiro
Copy link
Author

Hello All,

Thank you @owent for suggestion, I applied this suggestion, but fail again, incredible. If I try to run with the command "cmake --build ." I got the error:

root@LabC:/opt/helloworld/build# cmake --build .
Error: could not load cache

If try to run with the command: "cmake .. -DCMAKE_PREFIX_PATH=/opt/otelcpp/". I got the warnings and the error:

root@LabC:/opt/helloworld/build# cmake .. -DCMAKE_PREFIX_PATH=/opt/otelcpp/
-- Found thrift: /root/source/opentelemetry-cpp/tools/vcpkg
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found opentelemetry-cpp: /opt/otelcpp/include
-- otel c++ include dirs: /opt/otelcpp/include
-- otel c++ libs: opentelemetry-cpp::api;opentelemetry-cpp::sdk;opentelemetry-cpp::ext;opentelemetry-cpp::version;opentelemetry-cpp::common;opentelemetry-cpp::trace;opentelemetry-cpp::metrics;opentelemetry-cpp::in_memory_span_exporter;opentelemetry-cpp::otlp_recordable;opentelemetry-cpp::otlp_grpc_exporter;opentelemetry-cpp::otlp_http_client;opentelemetry-cpp::otlp_http_exporter;opentelemetry-cpp::ostream_span_exporter;opentelemetry-cpp::jaeger_trace_exporter;opentelemetry-cpp::http_client_curl
-- thrift libs:
-- Configuring done
CMake Warning (dev) in CMakeLists.txt:
Policy CMP0111 is not set: An imported target missing its location property
fails during generation. Run "cmake --help-policy CMP0111" for policy
details. Use the cmake_policy command to set the policy and suppress this
warning.

IMPORTED_LOCATION not set for imported target
"opentelemetry-cpp::ostream_span_exporter".
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) in CMakeLists.txt:
Policy CMP0111 is not set: An imported target missing its location property
fails during generation. Run "cmake --help-policy CMP0111" for policy
details. Use the cmake_policy command to set the policy and suppress this
warning.

IMPORTED_LOCATION not set for imported target
"opentelemetry-cpp::jaeger_trace_exporter".
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) in CMakeLists.txt:
Policy CMP0111 is not set: An imported target missing its location property
fails during generation. Run "cmake --help-policy CMP0111" for policy
details. Use the cmake_policy command to set the policy and suppress this
warning.

IMPORTED_LOCATION not set for imported target
"opentelemetry-cpp::otlp_grpc_exporter".
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) in CMakeLists.txt:
Policy CMP0111 is not set: An imported target missing its location property
fails during generation. Run "cmake --help-policy CMP0111" for policy
details. Use the cmake_policy command to set the policy and suppress this
warning.

IMPORTED_LOCATION not set for imported target
"opentelemetry-cpp::otlp_http_exporter".
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) in CMakeLists.txt:
Policy CMP0111 is not set: An imported target missing its location property
fails during generation. Run "cmake --help-policy CMP0111" for policy
details. Use the cmake_policy command to set the policy and suppress this
warning.

IMPORTED_LOCATION not set for imported target "opentelemetry-cpp::metrics".
This warning is for project developers. Use -Wno-dev to suppress it.

-- Generating done
-- Build files have been written to: /opt/helloworld/build
root@LabC:/opt/helloworld/build# cmake --build .
CMakeFiles/hello-otel.dir/build.make:95: *** target pattern contains no '%'. Stop.
make[1]: *** [CMakeFiles/Makefile2:82: CMakeFiles/hello-otel.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

@ThomsonTan
Copy link
Contributor

Both below build errors seem not opentelemetry-cpp specific. @ccoqueiro, can you clear the build folder and re-run both cmake .. and cmake --build . there?

Error: could not load cache
CMakeFiles/hello-otel.dir/build.make:95: *** target pattern contains no '%'. Stop.

@owent
Copy link
Member

owent commented May 10, 2022

@ccoqueiro

This problem may be the same as #705 . Could you please provide your opentelemetry-cpp-target*.cmake ? It may be you build opentelemetry with CMAKE_BUILD_TYPE<some name> but link it without or with another value.
Or you can try to add patch codes below after find_package(opentelemetry-cpp). Here is the full version of CMakeLists.txt.

cmake_minimum_required(VERSION 3.23)
project(otel-test)

find_package(Protobuf REQUIRED)
find_package(nlohmann_json REQUIRED)
find_package(CURL REQUIRED)
find_package(gRPC REQUIRED)
find_package(Thrift REQUIRED)
find_package(absl REQUIRED)
find_package(opentelemetry-cpp CONFIG REQUIRED)

# ============ Patch IMPORTED_VARS BEGIN ============
function(project_build_tools_patch_default_imported_config)
  set(PATCH_VARS
      IMPORTED_IMPLIB
      IMPORTED_LIBNAME
      IMPORTED_LINK_DEPENDENT_LIBRARIES
      IMPORTED_LINK_INTERFACE_LANGUAGES
      IMPORTED_LINK_INTERFACE_LIBRARIES
      IMPORTED_LINK_INTERFACE_MULTIPLICITY
      IMPORTED_LOCATION
      IMPORTED_NO_SONAME
      IMPORTED_OBJECTS
      IMPORTED_SONAME)
  foreach(TARGET_NAME ${ARGN})
    if(TARGET ${TARGET_NAME})
      get_target_property(IS_IMPORTED_TARGET ${TARGET_NAME} IMPORTED)
      if(NOT IS_IMPORTED_TARGET)
        continue()
      endif()

      if(CMAKE_VERSION VERSION_LESS "3.19.0")
        get_target_property(TARGET_TYPE_NAME ${TARGET_NAME} TYPE)
        if(TARGET_TYPE_NAME STREQUAL "INTERFACE_LIBRARY")
          continue()
        endif()
      endif()

      get_target_property(DO_NOT_OVERWRITE ${TARGET_NAME} IMPORTED_LOCATION)
      if(DO_NOT_OVERWRITE)
        continue()
      endif()

      if(CMAKE_VERSION VERSION_LESS "3.19.0")
        get_target_property(TARGET_TYPE_NAME ${TARGET_NAME} TYPE)
        if(TARGET_TYPE_NAME STREQUAL "INTERFACE_LIBRARY")
          continue()
        endif()
      endif()

      # MSVC's STL and debug level must match the target, so we can only move out IMPORTED_LOCATION_NOCONFIG
      if(MSVC)
        set(PATCH_IMPORTED_CONFIGURATION "NOCONFIG")
      else()
        get_target_property(PATCH_IMPORTED_CONFIGURATION ${TARGET_NAME} IMPORTED_CONFIGURATIONS)
      endif()

      if(NOT PATCH_IMPORTED_CONFIGURATION)
        continue()
      endif()

      get_target_property(PATCH_TARGET_LOCATION ${TARGET_NAME} "IMPORTED_LOCATION_${PATCH_IMPORTED_CONFIGURATION}")
      if(NOT PATCH_TARGET_LOCATION)
        continue()
      endif()

      foreach(PATCH_IMPORTED_KEY IN LISTS PATCH_VARS)
        get_target_property(PATCH_IMPORTED_VALUE ${TARGET_NAME} "${PATCH_IMPORTED_KEY}_${PATCH_IMPORTED_CONFIGURATION}")
        if(PATCH_IMPORTED_VALUE)
          set_target_properties(${TARGET_NAME} PROPERTIES "${PATCH_IMPORTED_KEY}" "${PATCH_IMPORTED_VALUE}")
        endif()
      endforeach()
    endif()
  endforeach()
endfunction()

set(THIRD_PARTY_OPENTELEMETRY_CPP_LINK_NAMES ${OPENTELEMETRY_CPP_LIBRARIES})
set(_IMPLICIT_OPENTELEMETRY_CPP_TARGETS opentelemetry-cpp::resources opentelemetry-cpp::proto
                                        opentelemetry-cpp::otlp_recordable)
foreach(_IMPLICIT_OPENTELEMETRY_CPP_TARGET IN LISTS _IMPLICIT_OPENTELEMETRY_CPP_TARGETS)
  if(TARGET ${_IMPLICIT_OPENTELEMETRY_CPP_TARGET}
      AND NOT ${_IMPLICIT_OPENTELEMETRY_CPP_TARGET} IN_LIST
          THIRD_PARTY_OPENTELEMETRY_CPP_LINK_NAMES)
    list(APPEND THIRD_PARTY_OPENTELEMETRY_CPP_LINK_NAMES
          ${_IMPLICIT_OPENTELEMETRY_CPP_TARGET})
  endif()
endforeach()
unset(_IMPLICIT_OPENTELEMETRY_CPP_TARGET)
unset(_IMPLICIT_OPENTELEMETRY_CPP_TARGETS)

project_build_tools_patch_default_imported_config(CURL::libcurl
  prometheus-cpp::core prometheus-cpp::pull prometheus-cpp::push
  civetweb::civetweb-cpp civetweb::civetweb)
project_build_tools_patch_default_imported_config(
  ${THIRD_PARTY_OPENTELEMETRY_CPP_LINK_NAMES})

# ------------ Patch IMPORTED_VARS END ------------

message(STATUS "otel c++ include dirs: ${OPENTELEMETRY_CPP_INCLUDE_DIRS}")
message(STATUS "otel c++ libs: ${OPENTELEMETRY_CPP_LIBRARIES}")
message(STATUS "thrift libs: ${THRIFT_FOUND_LIB}")

add_executable(hello-otel main.cpp)

target_link_libraries(hello-otel opentelemetry-cpp::ostream_span_exporter opentelemetry-cpp::jaeger_trace_exporter opentelemetry-cpp::otlp_grpc_exporter opentelemetry-cpp::otlp_grpc_log_exporter opentelemetry-cpp::otlp_http_exporter opentelemetry-cpp::metrics opentelemetry-cpp::sdk)

@ccoqueiro
Copy link
Author

Hello @ThomsonTan ! Sure, I cleaned the builder folder and re-run the command cmake .., I got the error:

root@LabC:/opt/helloworld/build# cmake ..
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found thrift: /root/source/opentelemetry-cpp/tools/vcpkg
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found opentelemetry-cpp: /usr/local/include
-- otel c++ include dirs: /usr/local/include
-- otel c++ libs: opentelemetry-cpp::api;opentelemetry-cpp::sdk;opentelemetry-cpp::ext;opentelemetry-cpp::version;opentelemetry-cpp::common;opentelemetry-cpp::trace;opentelemetry-cpp::metrics;opentelemetry-cpp::in_memory_span_exporter;opentelemetry-cpp::otlp_recordable;opentelemetry-cpp::otlp_grpc_exporter;opentelemetry-cpp::otlp_http_client;opentelemetry-cpp::otlp_http_exporter;opentelemetry-cpp::ostream_span_exporter;opentelemetry-cpp::jaeger_trace_exporter;opentelemetry-cpp::http_client_curl
-- thrift libs:
-- Configuring done
CMake Error at /usr/local/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-target.cmake:56 (set_target_properties):
The link interface of target "opentelemetry-cpp::proto" contains:

protobuf::libprotobuf

but the target was not found. Possible reasons include:

* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.

Call Stack (most recent call first):
/usr/local/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-config.cmake:86 (include)
CMakeLists.txt:5 (find_package)

CMake Error at /usr/local/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-target.cmake:63 (set_target_properties):
The link interface of target "opentelemetry-cpp::api" contains:

absl::bad_variant_access

but the target was not found. Possible reasons include:

* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.

Call Stack (most recent call first):
/usr/local/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-config.cmake:86 (include)
CMakeLists.txt:5 (find_package)

CMake Error at /usr/local/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-target.cmake:121 (set_target_properties):
The link interface of target "opentelemetry-cpp::http_client_curl"
contains:

CURL::libcurl

but the target was not found. Possible reasons include:

* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.

Call Stack (most recent call first):
/usr/local/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-config.cmake:86 (include)
CMakeLists.txt:5 (find_package)

CMake Error at /usr/local/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-target.cmake:143 (set_target_properties):
The link interface of target "opentelemetry-cpp::otlp_grpc_exporter"
contains:

gRPC::grpc++

but the target was not found. Possible reasons include:

* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.

Call Stack (most recent call first):
/usr/local/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-config.cmake:86 (include)
CMakeLists.txt:5 (find_package)

CMake Error at /usr/local/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-target.cmake:150 (set_target_properties):
The link interface of target "opentelemetry-cpp::otlp_grpc_log_exporter"
contains:

gRPC::grpc++

but the target was not found. Possible reasons include:

* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.

Call Stack (most recent call first):
/usr/local/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-config.cmake:86 (include)
CMakeLists.txt:5 (find_package)

CMake Error at /usr/local/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-target.cmake:157 (set_target_properties):
The link interface of target "opentelemetry-cpp::otlp_http_client"
contains:

nlohmann_json::nlohmann_json

but the target was not found. Possible reasons include:

* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.

Call Stack (most recent call first):
/usr/local/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-config.cmake:86 (include)
CMakeLists.txt:5 (find_package)

-- Generating done
CMake Generate step failed. Build files cannot be regenerated correctly.

I never really thought that building a simple hello world was something close to the impossible :-(

@owent
Copy link
Member

owent commented May 11, 2022

Hello @ThomsonTan ! Sure, I cleaned the builder folder and re-run the command cmake .., I got the error:

root@LabC:/opt/helloworld/build# cmake .. -- The C compiler identification is GNU 9.4.0 -- The CXX compiler identification is GNU 9.4.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found thrift: /root/source/opentelemetry-cpp/tools/vcpkg -- Looking for pthread.h -- Looking for pthread.h - found -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - found -- Found Threads: TRUE -- Found opentelemetry-cpp: /usr/local/include -- otel c++ include dirs: /usr/local/include -- otel c++ libs: opentelemetry-cpp::api;opentelemetry-cpp::sdk;opentelemetry-cpp::ext;opentelemetry-cpp::version;opentelemetry-cpp::common;opentelemetry-cpp::trace;opentelemetry-cpp::metrics;opentelemetry-cpp::in_memory_span_exporter;opentelemetry-cpp::otlp_recordable;opentelemetry-cpp::otlp_grpc_exporter;opentelemetry-cpp::otlp_http_client;opentelemetry-cpp::otlp_http_exporter;opentelemetry-cpp::ostream_span_exporter;opentelemetry-cpp::jaeger_trace_exporter;opentelemetry-cpp::http_client_curl -- thrift libs: -- Configuring done CMake Error at /usr/local/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-target.cmake:56 (set_target_properties): The link interface of target "opentelemetry-cpp::proto" contains:

protobuf::libprotobuf

but the target was not found. Possible reasons include:

* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.

Call Stack (most recent call first): /usr/local/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-config.cmake:86 (include) CMakeLists.txt:5 (find_package)

CMake Error at /usr/local/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-target.cmake:63 (set_target_properties): The link interface of target "opentelemetry-cpp::api" contains:

absl::bad_variant_access

but the target was not found. Possible reasons include:

* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.

Call Stack (most recent call first): /usr/local/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-config.cmake:86 (include) CMakeLists.txt:5 (find_package)

CMake Error at /usr/local/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-target.cmake:121 (set_target_properties): The link interface of target "opentelemetry-cpp::http_client_curl" contains:

CURL::libcurl

but the target was not found. Possible reasons include:

* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.

Call Stack (most recent call first): /usr/local/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-config.cmake:86 (include) CMakeLists.txt:5 (find_package)

CMake Error at /usr/local/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-target.cmake:143 (set_target_properties): The link interface of target "opentelemetry-cpp::otlp_grpc_exporter" contains:

gRPC::grpc++

but the target was not found. Possible reasons include:

* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.

Call Stack (most recent call first): /usr/local/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-config.cmake:86 (include) CMakeLists.txt:5 (find_package)

CMake Error at /usr/local/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-target.cmake:150 (set_target_properties): The link interface of target "opentelemetry-cpp::otlp_grpc_log_exporter" contains:

gRPC::grpc++

but the target was not found. Possible reasons include:

* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.

Call Stack (most recent call first): /usr/local/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-config.cmake:86 (include) CMakeLists.txt:5 (find_package)

CMake Error at /usr/local/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-target.cmake:157 (set_target_properties): The link interface of target "opentelemetry-cpp::otlp_http_client" contains:

nlohmann_json::nlohmann_json

but the target was not found. Possible reasons include:

* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.

Call Stack (most recent call first): /usr/local/lib/cmake/opentelemetry-cpp/opentelemetry-cpp-config.cmake:86 (include) CMakeLists.txt:5 (find_package)

-- Generating done CMake Generate step failed. Build files cannot be regenerated correctly.

I never really thought that building a simple hello world was something close to the impossible :-(

Sorry for my mistake. The depended libraries need find_package(...), I should not remove them before.

find_package(Protobuf REQUIRED)
find_package(nlohmann_json REQUIRED)
find_package(CURL REQUIRED)
find_package(gRPC REQUIRED)
find_package(Thrift REQUIRED)
find_package(absl REQUIRED)
find_package(opentelemetry-cpp CONFIG REQUIRED)

And maybe we also need patch some of these packages.

project_build_tools_patch_default_imported_config(CURL::libcurl
  prometheus-cpp::core prometheus-cpp::pull prometheus-cpp::push
  civetweb::civetweb-cpp civetweb::civetweb)

I have update the CMakeLists.txt above.

@ccoqueiro
Copy link
Author

Hello @owent !! Thank you so much!! Almost there, command cmake .. now runs without errors or warnings:

root@LabC:/opt/helloworld/build# cmake ..
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Protobuf: /usr/local/lib/libprotobuf.so;-lpthread (found version "3.19.2")
-- Found nlohmann_json: /usr/local/lib/cmake/nlohmann_json/nlohmann_jsonConfig.cmake (found version "3.9.1")
-- Found CURL: /usr/lib/x86_64-linux-gnu/libcurl.so (found version "7.68.0")
-- Found Threads: TRUE
-- Found thrift: /root/source/opentelemetry-cpp/tools/vcpkg
-- Found opentelemetry-cpp: /usr/local/include
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.a (found version "1.1.1f")
-- otel c++ include dirs: /usr/local/include
-- otel c++ libs: opentelemetry-cpp::api;opentelemetry-cpp::sdk;opentelemetry-cpp::ext;opentelemetry-cpp::version;opentelemetry-cpp::common;opentelemetry-cpp::trace;opentelemetry-cpp::metrics;opentelemetry-cpp::in_memory_span_exporter;opentelemetry-cpp::otlp_recordable;opentelemetry-cpp::otlp_grpc_exporter;opentelemetry-cpp::otlp_http_client;opentelemetry-cpp::otlp_http_exporter;opentelemetry-cpp::ostream_span_exporter;opentelemetry-cpp::jaeger_trace_exporter;opentelemetry-cpp::http_client_curl
-- thrift libs:
-- Configuring done
-- Generating done
-- Build files have been written to: /opt/helloworld/build

But when I ran the command cmake --build . I got this error:

root@LabC:/opt/helloworld/build# cmake --build .
[ 50%] Building CXX object CMakeFiles/hello-otel.dir/main.cpp.o
make[2]: *** No rule to make target '/root/source/opentelemetry-cpp/tools/vcpkg/packages/thrift_x64-linux/lib/libssl.a', needed by 'hello-otel'. Stop.
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/hello-otel.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

@owent
Copy link
Member

owent commented May 11, 2022

Hello @owent !! Thank you so much!! Almost there, command cmake .. now runs without errors or warnings:

root@LabC:/opt/helloworld/build# cmake .. -- The C compiler identification is GNU 9.4.0 -- The CXX compiler identification is GNU 9.4.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found Protobuf: /usr/local/lib/libprotobuf.so;-lpthread (found version "3.19.2") -- Found nlohmann_json: /usr/local/lib/cmake/nlohmann_json/nlohmann_jsonConfig.cmake (found version "3.9.1") -- Found CURL: /usr/lib/x86_64-linux-gnu/libcurl.so (found version "7.68.0") -- Found Threads: TRUE -- Found thrift: /root/source/opentelemetry-cpp/tools/vcpkg -- Found opentelemetry-cpp: /usr/local/include -- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.a (found version "1.1.1f") -- otel c++ include dirs: /usr/local/include -- otel c++ libs: opentelemetry-cpp::api;opentelemetry-cpp::sdk;opentelemetry-cpp::ext;opentelemetry-cpp::version;opentelemetry-cpp::common;opentelemetry-cpp::trace;opentelemetry-cpp::metrics;opentelemetry-cpp::in_memory_span_exporter;opentelemetry-cpp::otlp_recordable;opentelemetry-cpp::otlp_grpc_exporter;opentelemetry-cpp::otlp_http_client;opentelemetry-cpp::otlp_http_exporter;opentelemetry-cpp::ostream_span_exporter;opentelemetry-cpp::jaeger_trace_exporter;opentelemetry-cpp::http_client_curl -- thrift libs: -- Configuring done -- Generating done -- Build files have been written to: /opt/helloworld/build

But when I ran the command cmake --build . I got this error:

root@LabC:/opt/helloworld/build# cmake --build . [ 50%] Building CXX object CMakeFiles/hello-otel.dir/main.cpp.o make[2]: *** No rule to make target '/root/source/opentelemetry-cpp/tools/vcpkg/packages/thrift_x64-linux/lib/libssl.a', needed by 'hello-otel'. Stop. make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/hello-otel.dir/all] Error 2 make: *** [Makefile:91: all] Error 2

When you build opentelemetry with vcpkg. it's required to load toolchain of that vcpkg when run cmake.
Please try run cmake with cmake .. -DCMAKE_TOOLCHAIN_FILE=/root/source/opentelemetry-cpp/tools/vcpkg/scripts/buildsystems/vcpkg.cmake .

@lalitb @ThomsonTan Should we document this when we use internal submodule of vcpkg?

@ccoqueiro
Copy link
Author

Hello @owent !! Finally compiled the code and generated the executeable without errors or warnings, super thank you, I have no words that can express my gratitude,

@lalitb
Copy link
Member

lalitb commented May 11, 2022

@lalitb @ThomsonTan Should we document this when we use internal submodule of vcpkg?

Yes, I think it is good idea to document this in INSTALL.md under cmake build section.

@owent
Copy link
Member

owent commented May 12, 2022

@lalitb @ThomsonTan Should we document this when we use internal submodule of vcpkg?

Yes, I think it is good idea to document this in INSTALL.md under cmake build section.

I suggest to add a FAQ section to collect these problems.In my experience, the problems in this issue do not always happen, it depends how to use cmake and the version and cmake.

@lalitb
Copy link
Member

lalitb commented May 12, 2022

Ok, my bad. I thought you meant documenting how to use vcpkg for installing dependencies. I think a separate troubleshooting/faq page would be a good idea to have for these specific problems.

@ThomsonTan
Copy link
Contributor

When you build opentelemetry with vcpkg. it's required to load toolchain of that vcpkg when run cmake. Please try run cmake with cmake .. -DCMAKE_TOOLCHAIN_FILE=/root/source/opentelemetry-cpp/tools/vcpkg/scripts/buildsystems/vcpkg.cmake .

@lalitb @ThomsonTan Should we document this when we use internal submodule of vcpkg?

Besides adding the doc, could we add some check to our CMake list file, like if otel-cpp is built with vcpkg, the user import it should also use vcpkg (with the toolchain file specified)?

@owent
Copy link
Member

owent commented May 14, 2022

When you build opentelemetry with vcpkg. it's required to load toolchain of that vcpkg when run cmake. Please try run cmake with cmake .. -DCMAKE_TOOLCHAIN_FILE=/root/source/opentelemetry-cpp/tools/vcpkg/scripts/buildsystems/vcpkg.cmake .
@lalitb @ThomsonTan Should we document this when we use internal submodule of vcpkg?

Besides adding the doc, could we add some check to our CMake list file, like if otel-cpp is built with vcpkg, the user import it should also use vcpkg (with the toolchain file specified)?

Good idea.

@ccoqueiro
Copy link
Author

Hello All,

I thank you too much for the support of all of you, after a month trying to compile a simple C++ code, I was able to compile with the information you passed here, this last parameter was last(cmake .. -DCMAKE_TOOLCHAIN_FILE=/root/source/opentelemetry-cpp/tools/vcpkg/scripts/buildsystems/vcpkg.cmake .), through it I managed to compile the code, next step is now to try to generate a trace, which will be the subject of another discussion.

Thank you so much again
Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Good for taking. Extra help will be provided by maintainers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants