DataDog / dd-opentracing-cpp

Datadog Opentracing C++ Client
Apache License 2.0
40 stars 40 forks source link

dd-opentracing-cpp Win x64 Error opentracing dependency missing from CMakeLists.txt - LNK2019 unresolved external symbol propagation_error_category #268

Open buzz3791 opened 1 year ago

buzz3791 commented 1 year ago

I’ve modified our C++ application to use DataDog. I’ve added:

  1. the following include:
    #include <opentracing/dynamic_load.h>
  2. the DataDog include folder:
    dd-opentracing-cpp\.build\vcpkg_installed\x64-windows\include
  3. the DataDog link library folder:
    dd-opentracing-cpp\.build\RelWithDebInfo
  4. the DataDog link library: dd_opentracing.lib After the changes above, when building our C++ application with Visual Studio, the build is failing at link time with these DataDog related errors:
    
    Error        LNK2019        unresolved external symbol "__declspec(dllimport) class std::error_category const & __cdecl opentracing::v3::propagation_error_category(void)" (__imp_?propagation_error_category@v3@opentracing@@YAAEBVerror_category@std@@XZ) referenced in function "void __cdecl opentracing::v3::`dynamic initializer for 'invalid_carrier_error''(void)" (??__Einvalid_carrier_error@v3@opentracing@@YAXXZ)        someapp        C:\dev\mvtrunk\someapp\someapp\someapp.obj

Error LNK2019 unresolved external symbol "declspec(dllimport) class std::error_category const & __cdecl opentracing::v3::tracer_factory_error_category(void)" (imp_?tracer_factory_error_category@v3@opentracing@@YAAEBVerror_category@std@@XZ) referenced in function "void cdecl opentracing::v3::`dynamic initializer for 'configuration_parse_error''(void)" (??Econfiguration_parse_error@v3@opentracing@@YAXXZ) someapp C:\dev\mvtrunk\someapp\someapp\someapp.obj

Error LNK2019 unresolved external symbol "declspec(dllimport) class std::error_category const & __cdecl opentracing::v3::dynamic_load_error_category(void)" (imp_?dynamic_load_error_category@v3@opentracing@@YAAEBVerror_category@std@@XZ) referenced in function "void __cdecl opentracing::v3::`dynamic initializer for 'dynamic_load_failure_error''(void)" (??__Edynamic_load_failure_error@v3@opentracing@@YAXXZ) someapp C:\dev\mvtrunk\someapp\someapp\someapp.obj

buzz3791 commented 1 year ago

@dgoffredo Any ideas on why this issue is occuring? As far as I can tell, there are no DataDog .h nor .cpp files that are providing definitions of these *_error_category symbols.

dgoffredo commented 1 year ago

I haven't done a build on Windows, but I think that you will need opentracing-cpp's library in addition to dd-opentracing-cpp's.

The idea is that opentracing-cpp is a library that defines some interfaces (abstract classes), vocabulary types (e.g. errors, variants), and utilities (such as the plugin loader). A plugin is then another library, like dd-opentracing-cpp, that implements the interfaces and provides a hook for the plugin loader to load.

Even if you're not using the plugin loader, you will need both libraries in order to build an application using dd-opentracing-cpp.

For some non-Windows examples, see compiled-in or dynamic-loading. As part of both docker image setups, they call scripts/install_dependencies.sh, which installs the opentracing-cpp library.

raulbojalil commented 8 months ago

@buzz3791 Were you able to fix this issue? I'm having the same issue right now. I'm including the opentracing-cpp library as suggested by dgoffredo, but I'm still getting the error.

dgoffredo commented 8 months ago

Hi, @raulbojalil.

If @buzz3791 didn't find a solution that you can use, then please open up a Datadog Support ticket here. It will likely get escalated to my team, and then we can spend some time on Windows.

Note that dd-opentracing-cpp is no longer under active development. If you have the option of using a non-OpenTracing solution, then consider dd-trace-cpp instead.

If you want another vendor-agnostic solution, then you can look into opentelemetry-cpp. The Datadog Agent can act as an OTLP collector.