Closed jefjos closed 2 years ago
Thanks for reporting the issue with all relevant details. I had a quick run on the example posted above ( using cmake 3.15.2 - the one which is installed with me locally ), and was able to build it successfully. Will try it out with the cmake version used in the test above (i.e 3.19)
$ ls -ltr ..
total 12
-rw-rw-r-- 1 labhas labhas 127 Apr 27 07:00 main.cc
-rw-rw-r-- 1 labhas labhas 475 Apr 27 07:02 CMakeLists.txt
drwxrwxr-x 3 labhas labhas 4096 Apr 27 07:02 build
$ cmake ..
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/a/build
$ make
Scanning dependencies of target hello_cmake
[ 50%] Building CXX object CMakeFiles/hello_cmake.dir/main.cc.o
[100%] Linking CXX executable hello_cmake
[100%] Built target hello_cmake
$ ./hello_cmake
Hello CMake!
Ok. I validated using cmake-3.20.1 too, and it works fine. Can you ensure that opentelemetry-cpp is installed correctly in the system path, probably check the content of below directories ( on *nix/wsl ):
$ ls /usr/local/include/opentelemetry/
baggage common config.h context core detail exporters ext logs metrics nostd plugin sdk std trace version.h
$ ls /usr/local/lib/cmake/opentelemetry-cpp/
opentelemetry-cpp-config-version.cmake opentelemetry-cpp-config.cmake opentelemetry-cpp-target-noconfig.cmake opentelemetry-cpp-target.cmake
$ $ ls /usr/local/lib/libopentelemetry_*
/usr/local/lib/libopentelemetry_common.a /usr/local/lib/libopentelemetry_exporter_ostream_metrics.a /usr/local/lib/libopentelemetry_logs.a /usr/local/lib/libopentelemetry_resources.a /usr/local/lib/libopentelemetry_version.a
/usr/local/lib/libopentelemetry_exporter_ostream_logs.a /usr/local/lib/libopentelemetry_exporter_ostream_span.a /usr/local/lib/libopentelemetry_metrics.a /usr/local/lib/libopentelemetry_trace.a /usr/local/lib/libopentelemetry_zpages.a
Hi @lalitb ,
We have also tried linking cpp client , However facing similar issue. Platform - ubi8, rhel 8 Buildsystem -
[root@c75b9f14a114 build]# cmake --version
cmake version 3.19.6
CMake suite maintained and supported by Kitware (kitware.com/cmake)
Installation Steps:
# Build and install opentelemetry
RUN cd ~/dependencies && git clone --recurse-submodules https://github.com/open-telemetry/opentelemetry-cpp && \
cd opentelemetry-cpp && \
mkdir build && cd build && \
cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DWITH_OTLP=ON -DWITH_PROMETHEUS=ON -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX=/usr .. && \
cmake --build . --target all && \
cmake --install . --config Debug --prefix /usr
Observations:
[root@c75b9f14a114 build]# ls /usr/local/include/opentelemetry/
ls: cannot access '/usr/local/include/opentelemetry/': No such file or directory
[root@c75b9f14a114 build]# ls /usr/include/opentelemetry/
baggage common config.h context detail exporters ext logs metrics nostd plugin proto sdk std trace version.h
[root@c75b9f14a114 build]# ls /usr/lib/cmake/opentelemetry-cpp/
ls: cannot access '/usr/lib/cmake/opentelemetry-cpp/': No such file or directory
[root@c75b9f14a114 build]# ls /usr/lib64/cmake/opentelemetry-cpp/
opentelemetry-cpp-config-version.cmake opentelemetry-cpp-config.cmake opentelemetry-cpp-target.cmake
[root@c75b9f14a114 build]# ls /usr/local/lib/libopentelemetry_*
ls: cannot access '/usr/local/lib/libopentelemetry_*': No such file or directory
[root@c75b9f14a114 build]# ls /usr/lib64/libopentelemetry_*
/usr/lib64/libopentelemetry_common.a /usr/lib64/libopentelemetry_exporter_ostream_span.a /usr/lib64/libopentelemetry_metrics.a /usr/lib64/libopentelemetry_trace.a
/usr/lib64/libopentelemetry_exporter_ostream_logs.a /usr/lib64/libopentelemetry_exporter_otprotocol.a /usr/lib64/libopentelemetry_proto.a /usr/lib64/libopentelemetry_version.a
/usr/lib64/libopentelemetry_exporter_ostream_metrics.a /usr/lib64/libopentelemetry_logs.a /usr/lib64/libopentelemetry_resources.a /usr/lib64/libopentelemetry_zpages.a
Thanks, Nandisha
The only difference I can spot is I'm missing the file - opentelemetry-cpp-target-noconfig.cmake
@jefjos what is the linking issue? From the original post, there is CMake warnings but the build files were still produced. Would the build succeed based on that?
The subsequent build with ninja is failing with the following error
ninja
ninja: error: 'opentelemetry-cpp::version-NOTFOUND', needed by 'hello_cmake', missing and no known rule to make it
Installed OTEL files
ls /usr/local/include/opentelemetry/
baggage config.h detail ext metrics plugin std version.h
common context exporters logs nostd sdk trace
ls /usr/local/lib/
cmake libopentelemetry_metrics.a
libopentelemetry_common.a libopentelemetry_resources.a
libopentelemetry_exporter_ostream_logs.a libopentelemetry_trace.a
libopentelemetry_exporter_ostream_metrics.a libopentelemetry_version.a
libopentelemetry_exporter_ostream_span.a libopentelemetry_zpages.a
libopentelemetry_logs.a
ls /usr/local/lib/cmake/opentelemetry-cpp/
opentelemetry-cpp-config-version.cmake opentelemetry-cpp-target.cmake
opentelemetry-cpp-config.cmake
After manually copied the noconfig.cmake to lib directory able to link it.
[root@4831e0052c03 ~]# find / -name "opentelemetry-cpp-target-noconfig.cmake"
/root/dependencies/opentelemetry-cpp/build/CMakeFiles/Export/lib64/cmake/opentelemetry-cpp/opentelemetry-cpp-target-noconfig.cmake
[root@4831e0052c03 ~]# cp /root/dependencies/opentelemetry-cpp/build/CMakeFiles/Export/lib64/cmake/opentelemetry-cpp/opentelemetry-cpp-target-noconfig.cmake /usr/lib64/cmake/
[root@4831e0052c03 build]# cmake ..
-- Found Protobuf: /usr/local/bin/protoc-3.14.0.0 (found version "3.14.0.0")
-- Using protobuf -> 3.14.0.0
-- Using gRPC -> 1.35.0
-- Configuring done
-- Generating done
-- Build files have been written to: /root/dependencies/example2/build
[root@4831e0052c03 build]# make
Scanning dependencies of target hello_cmake
[ 50%] Building CXX object CMakeFiles/hello_cmake.dir/main.cc.o
[100%] Linking CXX executable hello_cmake
[100%] Built target hello_cmake
[root@4831e0052c03 build]# ./hello_cmake
Hello CMake!
The subsequent build with ninja is failing with the following error
ninja ninja: error: 'opentelemetry-cpp::version-NOTFOUND', needed by 'hello_cmake', missing and no known rule to make it
Installed OTEL files
ls /usr/local/include/opentelemetry/ baggage config.h detail ext metrics plugin std version.h common context exporters logs nostd sdk trace
ls /usr/local/lib/ cmake libopentelemetry_metrics.a libopentelemetry_common.a libopentelemetry_resources.a libopentelemetry_exporter_ostream_logs.a libopentelemetry_trace.a libopentelemetry_exporter_ostream_metrics.a libopentelemetry_version.a libopentelemetry_exporter_ostream_span.a libopentelemetry_zpages.a libopentelemetry_logs.a
ls /usr/local/lib/cmake/opentelemetry-cpp/ opentelemetry-cpp-config-version.cmake opentelemetry-cpp-target.cmake opentelemetry-cpp-config.cmake
@jefjos where is opentelemetry-cpp installed? I saw below option is passed to cmake, was it intended to install opentelemetry-cpp under the test project folder like hello-cmake/out
? If opentelemetry-cpp is installed to system default location like /usr/local/include and /usr/local/lib, below option should not be passed as a customized path.
-DCMAKE_INSTALL_PREFIX:PATH="hello-cmake/out/install/WSL-GCC-Debug"
I tried again after deleting all cached files and running cmake -G "Ninja"
Getting same warnings and build error
Have added the following lines in CMakeLists.txt as a workaround for now
set_target_properties(opentelemetry-cpp::version PROPERTIES IMPORTED_LOCATION "${OPENTELEMETRY_CPP_LIBRARY_DIRS}/libopentelemetry_version.a")
set_target_properties(opentelemetry-cpp::common PROPERTIES IMPORTED_LOCATION "${OPENTELEMETRY_CPP_LIBRARY_DIRS}/libopentelemetry_common.a")
set_target_properties(opentelemetry-cpp::trace PROPERTIES IMPORTED_LOCATION "${OPENTELEMETRY_CPP_LIBRARY_DIRS}/libopentelemetry_trace.a")
set_target_properties(opentelemetry-cpp::metrics PROPERTIES IMPORTED_LOCATION "${OPENTELEMETRY_CPP_LIBRARY_DIRS}/libopentelemetry_metrics.a")
set_target_properties(opentelemetry-cpp::logs PROPERTIES IMPORTED_LOCATION "${OPENTELEMETRY_CPP_LIBRARY_DIRS}/libopentelemetry_logs.a")
set_target_properties(opentelemetry-cpp::ostream_log_exporter PROPERTIES IMPORTED_LOCATION "${OPENTELEMETRY_CPP_LIBRARY_DIRS}/libopentelemetry_exporter_ostream_logs.a")
set_target_properties(opentelemetry-cpp::ostream_metrics_exporter PROPERTIES IMPORTED_LOCATION "${OPENTELEMETRY_CPP_LIBRARY_DIRS}/libopentelemetry_exporter_ostream_metrics.a")
set_target_properties(opentelemetry-cpp::ostream_span_exporter PROPERTIES IMPORTED_LOCATION "${OPENTELEMETRY_CPP_LIBRARY_DIRS}/libopentelemetry_exporter_ostream_span.a")
set_target_properties(opentelemetry-cpp::zpages PROPERTIES IMPORTED_LOCATION "${OPENTELEMETRY_CPP_LIBRARY_DIRS}/libopentelemetry_zpages.a")
set_target_properties(opentelemetry-cpp::resources PROPERTIES IMPORTED_LOCATION "${OPENTELEMETRY_CPP_LIBRARY_DIRS}/libopentelemetry_resources.a")
@jefjos based on your listing above, the problem is you are missing the configuration specific target CMake file in below directory, like opentelemetry-cpp-target-debug.cmake
. Could you please clean all the installed files for opentelemetry-cpp and re-build and re-install it? I did the build and installation in WSL as well and got the config file there.
ls /usr/local/lib/cmake/opentelemetry-cpp/ opentelemetry-cpp-config-version.cmake opentelemetry-cpp-target.cmake opentelemetry-cpp-config.cmake
The only difference I can spot is I'm missing the file - opentelemetry-cpp-target-noconfig.cmake
The cmake config file are installed under <CMAKE_INSTALL_PREFIX>/lib/cmake/opentelemetry-cpp
or <CMAKE_INSTALL_PREFIX>/lib64/cmake/opentelemetry-cpp
.
The opentelemetry-cpp-target.cmake
will include all opentelemetry-cpp-target-*.cmake
and the suffix of opentelemetry-cpp-target-*.cmake
depend on what you pass to --config
if you use cmake --build ...
to build.
For example:
When using cmake --build . --target install --config RedWithDebInfo
to build opentelemetry-cpp, opentelemetry-cpp-target-relwithdebinfo.cmake
will be installed.When nothing passed into --config
, opentelemetry-cpp-target-noconfig.cmake
will be installed.
@jefjos @nkrishnappa please update whether you are able to build it successfully with the latest release.
Please consider using codes below to move some properties out of CONFIG if there are still problems to link.
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(
${THIRD_PARTY_OPENTELEMETRY_CPP_LINK_NAMES})
This issue was marked as stale due to lack of activity. It will be closed in 7 days if no furthur activity occurs.
This issue was marked as stale due to lack of activity. It will be closed in 7 days if no furthur activity occurs.
This issue was marked as stale due to lack of activity. It will be closed in 7 days if no furthur activity occurs.
Closed as inactive. Feel free to reopen if this is still an issue.
Same issue. Built the Debian .deb package for 1.12.2 according to docs, but the package was missing the opentelemetry-cpp-target-noconfig.cmake
file.
I found it in my build directory, and copied it manually to /usr/lib/cmake/opentelemetry-cpp.
... and this happens because of cpack -C Debug
from https://github.com/open-telemetry/opentelemetry-cpp/blob/main/INSTALL.md
If I just do cpack
, the file is contained in the .deb package.
Describe your environment Describe any aspect of your environment relevant to the problem, including your platform, build system, version numbers of installed dependencies, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on main branch. Platform - WSL Buildsystem - CMake v3.19
Code
main.cpp
CMakeLists.txt
target_include_directories(hello_cmake PUBLIC ${OPENTELEMETRY_CPP_INCLUDE_DIRS}) target_link_libraries(hello_cmake PUBLIC ${OPENTELEMETRY_CPP_LIBRARIES})
Steps to reproduce Describe exactly how to reproduce the error. Include a code sample if applicable. I have attached a sample CMake code
cmake -G "Ninja" -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="hello-cmake/out/install/WSL-GCC-Debug" hello-cmake/CMakeLists.txt
What is the expected behavior? CMake Generation should happen without any warnings or errors
What is the actual behavior?
Additional context Add any other context about the problem here.