-
Notifications
You must be signed in to change notification settings - Fork 500
Description
Describe your environment
Same as in #3673
Steps to reproduce
Same as in #3673, except that ext/src/dll/input.src
is patched with the missing symbols listed in #3673 before building the opentelemetry-cpp DLL.
Then attempt to link the resulting import library on Windows into another shared library uses traces, exporters, resources, samplers, etc
What is the expected behavior?
What did you expect to see?
Successful link without unresolved symbols, just like on Linux.
What is the actual behavior?
What did you see instead?
14> Creating library <x86 or x64>\Release\project1\\project1.lib and object x64\Release\project1\\project1.exp
14>file1.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class opentelemetry::v2::nostd::shared_ptr<class opentelemetry::v2::context::propagation::TextMapPropagator> __cdecl opentelemetry::v2::context::propagation::GlobalTextMapPropagator::GetGlobalPropagator(void)" (__imp_?GetGlobalPropagator@GlobalTextMapPropagator@propagation@context@v2@opentelemetry@@SA?AV?$shared_ptr@VTextMapPropagator@propagation@context@v2@opentelemetry@@@nostd@45@XZ) referenced in function "<function1>)
14>file2.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static void __cdecl opentelemetry::v2::context::propagation::GlobalTextMapPropagator::SetGlobalPropagator(class opentelemetry::v2::nostd::shared_ptr<class opentelemetry::v2::context::propagation::TextMapPropagator> const &)" (__imp_?SetGlobalPropagator@GlobalTextMapPropagator@propagation@context@v2@opentelemetry@@SAXAEBV?$shared_ptr@VTextMapPropagator@propagation@context@v2@opentelemetry@@@nostd@45@@Z) referenced in function "<function2>)
14><path to final dll>\project1.dll : fatal error LNK1120: 2 unresolved externals
14>Done building project "project1.vcxproj" -- FAILED.
Additional context
This is because the GlobalPropagator class is annotated with the OPENTELEMETRY_EXPORT macro. It's a header-only class. Nothing inside opentelemetry-cpp source files actually uses the GlobalPropagator class. So the resulting DLL has no symbols corresponding to the GlobalPropagator class and/or methods.
Hence when we attempt to use the GlobalPropagator class in our code, OPENTELEMETRY_EXPORT is expanded into "__declspec(dllimport)" and hence the missing symbol.
If I remove OPENTELEMETRY_EXPORT from GlobalPropagator, then all is good and the link works. I suspect that if opentelemetry-cpp's sources actually used the GlobalPropagator class somewhere (or did not use static singletons in the header ...) then it would work with the OPENTELEMETRY_EXPORT macro.
Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1
or me too
, to help us triage it. Learn more here.