Why can't linker find absl references?
Configuration:
Raspberry Pi 4 Model B (AArch64) | Ubuntu Server 20.04 | Clang++ (llvm 13.0.0) | GRPC v1.41.1 (libprotoc 3.17.3)
Installed GRPC with these options:
cmake -DgRPC_INSTALL=ON -DCMAKE_BUILD_TYPE=Release -DgRPC_ABSL_PROVIDER=module -DgRPC_CARES_PROVIDER=module -DgRPC_PROTOBUF_PROVIDER=module -DgRPC_RE2_PROVIDER=module -DgRPC_SSL_PROVIDER=module -DgRPC_ZLIB_PROVIDER=module -j4 ../
sudo make install
Command:
clang++ -std=c++17 -iquote /home/ubuntu/gameserver/server/include -include /usr/local/include/grpcpp/support/method_handler.h -L /usr/local/lib src/gameserver.pb.cc src/gameserver.grpc.pb.cc server_test.cpp -lprotobuf -lpthread -ljsoncpp -lgrpc -lgrpc++ -lgrpc++_reflection -labsl_base -labsl_synchronization -labsl_malloc_internal -labsl_stacktrace -labsl_raw_logging_internal -labsl_time -labsl_graphcycles_internal -labsl_spinlock_wait -lgrpc_unsecure -lz -labsl_symbolize -lgpr -labsl_status -labsl_statusor -o server_test -v -Wl,--verbose
Linker finds base class (Found in this [header][1]) :
/usr/local/lib/libabsl_base.a
Error:
/usr/bin/ld: /usr/local/lib/libabsl_synchronization.a(mutex.cc.o): in function 'absl::lts_20210324::EnsureSynchEvent(std::atomic<long>*, char const*, long, long)':
mutex.cc:(.text+0x1f0): undefined reference to 'absl::lts_20210324::base_internal::SpinLock::SlowUnlock(unsigned int)'
Update #1:
Rebuilt/installed grpc
and absl
using -DCMAKE_CXX_STANDARD=17
just to make sure everything is on the same standard.
Found new error when modifying order of linked libraries...
New Command:
clang++ -iquote /home/ubuntu/gameserver/server/include -include /usr/local/include/grpcpp/support/method_handler.h -L /usr/local/lib src/gameserver.pb.cc src/gameserver.grpc.pb.cc server_test.cpp -o server_test -labsl_status -labsl_strings -lgrpc -lgrpc++ -labsl_synchronization -lgrpc_unsecure -labsl_base -lprotobuf -lpthread -ljsoncpp -lgrpc++_reflection -labsl_malloc_internal -labsl_stacktrace -labsl_raw_logging_internal -labsl_time -labsl_graphcycles_internal -labsl_spinlock_wait -lz -labsl_symbolize -lgpr -labsl_statusor -std=c++17 -v -Wl,--verbose
New Errors:
/usr/bin/ld: /usr/local/lib/libgrpc_unsecure.a(client_channel.cc.o): in function `grpc_core::ClientChannel::LoadBalancedCall::RecvTrailingMetadataReady(void*, grpc_error*)':
client_channel.cc:(.text+0x774): undefined reference to `absl::lts_20210324::Status::Status(absl::lts_20210324::StatusCode, std::basic_string_view<char, std::char_traits<char> >)'
/usr/bin/ld: client_channel.cc:(.text+0x8d8): undefined reference to `absl::lts_20210324::Status::Status(absl::lts_20210324::StatusCode, std::basic_string_view<char, std::char_traits<char> >)'
/usr/bin/ld: client_channel.cc:(.text+0x8e8): undefined reference to `absl::lts_20210324::Status::UnrefNonInlined(unsigned long)'
/usr/bin/ld: client_channel.cc:(.text+0x918): undefined reference to `absl::lts_20210324::Status::UnrefNonInlined(unsigned long)'
/usr/bin/ld: client_channel.cc:(.text+0x930): undefined reference to `absl::lts_20210324::Status::UnrefNonInlined(unsigned long)'
/usr/bin/ld: client_channel.cc:(.text+0xa2c): undefined reference to `absl::lts_20210324::Status::UnrefNonInlined(unsigned long)'
/usr/bin/ld: client_channel.cc:(.text+0xa38): undefined reference to `absl::lts_20210324::Status::UnrefNonInlined(unsigned long)'
/usr/bin/ld: /usr/local/lib/libgrpc_unsecure.a(client_channel.cc.o):client_channel.cc:(.text+0xa54): more undefined references to `absl::lts_20210324::Status::UnrefNonInlined(unsigned long)' follow
/usr/bin/ld: /usr/local/lib/libgrpc_unsecure.a(client_channel.cc.o): in function `std::_Function_handler<bool (grpc_core::LoadBalancingPolicy::PickResult::Drop*), grpc_core::ClientChannel::LoadBalancedCall::PickSubchannelLocked(grpc_error**)::{lambda(grpc_core::LoadBalancingPolicy::PickResult::Drop*)#4}>::_M_invoke(std::_Any_data const&, grpc_core::LoadBalancingPolicy::PickResult::Drop*&&)':
client_channel.cc:(.text+0x354c): undefined reference to `absl::lts_20210324::Status::ToStringSlow[abi:cxx11](absl::lts_20210324::StatusToStringMode) const'
/usr/bin/ld: client_channel.cc:(.text+0x3590): undefined reference to `absl::lts_20210324::Status::UnrefNonInlined(unsigned long)'
/usr/bin/ld: /usr/local/lib/libgrpc_unsecure.a(client_channel.cc.o): in function `std::_Function_handler<bool (grpc_core::LoadBalancingPolicy::PickResult::Fail*), grpc_core::ClientChannel::LoadBalancedCall::PickSubchannelLocked(grpc_error**)::{lambda(grpc_core::LoadBalancingPolicy::PickResult::Fail*)#3}>::_M_invoke(std::_Any_data const&, grpc_core::LoadBalancingPolicy::PickResult::Fail*&&)':
Update #2:
Rebuilt/installed absl
using -DCMAKE_CXX_FLAGS='-D_GLIBCXX_USE_CXX11_ABI=0'
as mentioned [here][2].
Still same error as update #1.
`...`
to get it inline, or for multi-line blocks, enclose between```
. If you use*
for italics as you did, it messes up output that contains a*
character. I have fixed your post for you, but please note this for the future. – Dall