-
Notifications
You must be signed in to change notification settings - Fork 443
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
Error linking OTEL library #705
Comments
Thanks for reporting the issue with all relevant details. $ 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. [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, |
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
Installed OTEL files
|
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!
|
@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
|
I tried again after deleting all cached files and running Getting same warnings and build error |
Have added the following lines in CMakeLists.txt as a workaround for now
|
@jefjos based on your listing above, the problem is you are missing the configuration specific target CMake file in below directory, like
|
The cmake config file are installed under |
@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 I found it in my build directory, and copied it manually to /usr/lib/cmake/opentelemetry-cpp. |
... and this happens because of If I just do |
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.
The text was updated successfully, but these errors were encountered: