errors about dynamic::TypeInfo when linking TLSCredProcessorTest
zjzzjz1979 opened this issue · 0 comments
zjzzjz1979 commented
[100%] Linking CXX executable bin/TLSCredProcessorTest
lib/libwangle.a(TLSCredProcessor.cpp.o): In function `std::vector<folly::dynamic, std::allocator<folly::dynamic> >& folly::dynamic::get<std::vector<folly::dynamic, std::allocator<folly::dynamic> > >()':
TLSCredProcessor.cpp:(.text._ZN5folly7dynamic3getISt6vectorIS0_SaIS0_EEEERT_v[_ZN5folly7dynamic3getISt6vectorIS0_SaIS0_EEEERT_v]+0x65): undefined reference to `folly::dynamic::TypeInfo<std::vector<folly::dynamic, std::allocator<folly::dynamic> > >::name'
lib/libwangle.a(TLSCredProcessor.cpp.o): In function `folly::dynamic::ObjectImpl& folly::dynamic::get<folly::dynamic::ObjectImpl>()':
TLSCredProcessor.cpp:(.text._ZN5folly7dynamic3getINS0_10ObjectImplEEERT_v[_ZN5folly7dynamic3getINS0_10ObjectImplEEERT_v]+0x65): undefined reference to `folly::dynamic::TypeInfo<folly::dynamic::ObjectImpl>::name'
lib/libwangle.a(TLSCredProcessor.cpp.o): In function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >& folly::dynamic::get<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >()':
TLSCredProcessor.cpp:(.text._ZN5folly7dynamic3getINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEERT_v[_ZN5folly7dynamic3getINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEERT_v]+0x65): undefined reference to `folly::dynamic::TypeInfo<std::__cxx11::basic_string<cha
r, std::char_traits<char>, std::allocator<char> > >::name'
collect2: error: ld returned 1 exit status
CMakeFiles/TLSCredProcessorTest.dir/build.make:154: recipe for target 'bin/TLSCredProcessorTest' failed
make[2]: *** [bin/TLSCredProcessorTest] Error 1
CMakeFiles/Makefile2:622: recipe for target 'CMakeFiles/TLSCredProcessorTest.dir/all' failed
make[1]: *** [CMakeFiles/TLSCredProcessorTest.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
I feel this is related the constexpr anem at https://github.com/facebook/folly/blob/master/folly/dynamic.cpp
#define FOLLY_DYNAMIC_DEF_TYPEINFO(T) \
constexpr const char* dynamic::TypeInfo<T>::name; \
constexpr dynamic::Type dynamic::TypeInfo<T>::type; \
//
If the code is designed in this way, will compiler or linker still expose the definition? I tried to move the definition to folly/dynamic-int.h. The error was gone. However, is this the correct fix?
Does anyone else have the similar issue?