Skip to content
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

C++: Undefine reference to functions defined in absl::lts_20230125 #12292

Closed
ToKiNoBug opened this issue Mar 21, 2023 · 50 comments
Closed

C++: Undefine reference to functions defined in absl::lts_20230125 #12292

ToKiNoBug opened this issue Mar 21, 2023 · 50 comments

Comments

@ToKiNoBug
Copy link

ToKiNoBug commented Mar 21, 2023

What version of protobuf and what language are you using?
Version: v22.2
Language: C++

What operating system (Linux, Windows, ...) and version?
Windows 11
What runtime / compiler are you using (e.g., python version or gcc version)
gcc12.2.0 (mingw)
What did you do?

  1. Build and install protobuf from source code, and install it into the prefix of gcc.
  2. Write the following cmake project containing 3 files: CMakeLists.txt, test.proto and main.cpp. They are located in same dir.
#CMakeLists.txt
find_package(protobuf REQUIRED)

protobuf_generate_cpp(pb_src pb_hdr test.proto)

add_library(test_pb_lib ${pb_hdr} ${pb_src})
target_include_directories(test_pb_lib INTERFACE ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(test_pb_lib PUBLIC protobuf::libprotobuf)

add_executable(test_pb main.cpp)
target_link_libraries(test_pb PRIVATE test_pb_lib)
// test.proto
syntax = "proto3";

message test {
  int32 msg = 1;
}
// main.cpp
#include <iostream>

#include <test.pb.h>

int main(int, char **) {

  ::test test_msg;

  std::cout << "Hello, world!\n";
}
  1. Configure my cmake project
cmake.EXE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=D:/ProgramFilesU/gcc-compilers/mingw-gcc12/bin/gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=D:/ProgramFilesU/gcc-compilers/mingw-gcc12/bin/g++.exe -SD:/Git/learnProtobuf -Bd:/Git/build-learnProtobuf-win -G Ninja
  1. Build the project
cmake --build .

What did you expect to see

My code is compiled with no error.

What did you see instead?

22 errors was reported:

[main] Building folder: learnProtobuf 
[build] Starting build
[proc] Executing command: D:\ProgramFiles\CMake\bin\cmake.EXE --build d:/Git/build-learnProtobuf-win --config Debug --target all --parallel --
[build] [1/1 100% :: 0.167] Linking CXX executable test_pb.exe
[build] FAILED: test_pb.exe 
[build] cmd.exe /C "cd . && D:\ProgramFilesU\gcc-compilers\mingw-gcc12\bin\g++.exe -g  CMakeFiles/test_pb.dir/main.obj -o test_pb.exe -Wl,--out-implib,libtest_pb.dll.a -Wl,--major-image-version,0,--minor-image-version,0  libtest_pb_lib.a  D:/ProgramFilesU/gcc-compilers/mingw-gcc12/lib/libprotobuf.dll.a  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
[build] D:/ProgramFilesU/gcc-compilers/mingw-gcc12/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libtest_pb_lib.a(test.pb.obj): in function `test::MergeImpl(google::protobuf::Message&, google::protobuf::Message const&)':
[build] D:/Git/build-learnProtobuf-win/test.pb.cc:243: undefined reference to `absl::lts_20230125::log_internal::LogMessageFatal::LogMessageFatal(char const*, int, std::basic_string_view<char, std::char_traits<char> >)'
[build] D:/ProgramFilesU/gcc-compilers/mingw-gcc12/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/Git/build-learnProtobuf-win/test.pb.cc:243: undefined reference to `absl::lts_20230125::log_internal::LogMessageFatal::~LogMessageFatal()'
[build] D:/ProgramFilesU/gcc-compilers/mingw-gcc12/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libtest_pb_lib.a(test.pb.obj): in function `absl::lts_20230125::log_internal::LogMessage::operator<<(unsigned long long)':
[build] D:/ProgramFilesU/gcc-compilers/mingw-gcc12/include/absl/log/internal/log_message.h:123: undefined reference to `absl::lts_20230125::log_internal::LogMessage& absl::lts_20230125::log_internal::LogMessage::operator<< <unsigned long long, 0>(unsigned long long const&)'
[build] D:/ProgramFilesU/gcc-compilers/mingw-gcc12/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libtest_pb_lib.a(test.pb.obj): in function `google::protobuf::internal::ArenaAlignAs(unsigned long long)':
[build] D:/ProgramFilesU/gcc-compilers/mingw-gcc12/include/google/protobuf/arena_align.h:178: undefined reference to `absl::lts_20230125::log_internal::LogMessageFatal::LogMessageFatal(char const*, int, std::basic_string_view<char, std::char_traits<char> >)'
[build] D:/ProgramFilesU/gcc-compilers/mingw-gcc12/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/ProgramFilesU/gcc-compilers/mingw-gcc12/include/google/protobuf/arena_align.h:178: undefined reference to `absl::lts_20230125::log_internal::LogMessageFatal::~LogMessageFatal()'
[build] D:/ProgramFilesU/gcc-compilers/mingw-gcc12/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/ProgramFilesU/gcc-compilers/mingw-gcc12/include/google/protobuf/arena_align.h:179: undefined reference to `absl::lts_20230125::log_internal::LogMessageFatal::LogMessageFatal(char const*, int, std::basic_string_view<char, std::char_traits<char> >)'
[build] D:/ProgramFilesU/gcc-compilers/mingw-gcc12/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/ProgramFilesU/gcc-compilers/mingw-gcc12/include/google/protobuf/arena_align.h:179: undefined reference to `absl::lts_20230125::log_internal::LogMessageFatal::~LogMessageFatal()'
[build] D:/ProgramFilesU/gcc-compilers/mingw-gcc12/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/ProgramFilesU/gcc-compilers/mingw-gcc12/include/google/protobuf/arena_align.h:179: undefined reference to `absl::lts_20230125::log_internal::LogMessageFatal::~LogMessageFatal()'
[build] D:/ProgramFilesU/gcc-compilers/mingw-gcc12/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libtest_pb_lib.a(test.pb.obj): in function `google::protobuf::internal::EpsCopyInputStream::DoneWithCheck(char const**, int)':
[build] D:/ProgramFilesU/gcc-compilers/mingw-gcc12/include/google/protobuf/parse_context.h:241: undefined reference to `absl::lts_20230125::log_internal::LogMessageFatal::LogMessageFatal(char const*, int, std::basic_string_view<char, std::char_traits<char> >)'
[build] D:/ProgramFilesU/gcc-compilers/mingw-gcc12/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/ProgramFilesU/gcc-compilers/mingw-gcc12/include/google/protobuf/parse_context.h:241: undefined reference to `absl::lts_20230125::log_internal::LogMessageFatal::~LogMessageFatal()'
[build] D:/ProgramFilesU/gcc-compilers/mingw-gcc12/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/ProgramFilesU/gcc-compilers/mingw-gcc12/include/google/protobuf/parse_context.h:244: undefined reference to `absl::lts_20230125::log_internal::LogMessageFatal::LogMessageFatal(char const*, int, std::basic_string_view<char, std::char_traits<char> >)'
[build] D:/ProgramFilesU/gcc-compilers/mingw-gcc12/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/ProgramFilesU/gcc-compilers/mingw-gcc12/include/google/protobuf/parse_context.h:244: undefined reference to `absl::lts_20230125::log_internal::LogMessageFatal::~LogMessageFatal()'
[build] D:/ProgramFilesU/gcc-compilers/mingw-gcc12/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/ProgramFilesU/gcc-compilers/mingw-gcc12/include/google/protobuf/parse_context.h:241: undefined reference to `absl::lts_20230125::log_internal::LogMessageFatal::~LogMessageFatal()'
[build] D:/ProgramFilesU/gcc-compilers/mingw-gcc12/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libtest_pb_lib.a(test.pb.obj): in function `test::SharedDtor()':
[build] D:/Git/build-learnProtobuf-win/test.pb.cc:139: undefined reference to `absl::lts_20230125::log_internal::LogMessageFatal::LogMessageFatal(char const*, int, std::basic_string_view<char, std::char_traits<char> >)'
[build] D:/ProgramFilesU/gcc-compilers/mingw-gcc12/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/Git/build-learnProtobuf-win/test.pb.cc:139: undefined reference to `absl::lts_20230125::log_internal::LogMessageFatal::~LogMessageFatal()'
[build] D:/ProgramFilesU/gcc-compilers/mingw-gcc12/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/Git/build-learnProtobuf-win/test.pb.cc:139: undefined reference to `absl::lts_20230125::log_internal::LogMessageFatal::~LogMessageFatal()'
[build] D:/ProgramFilesU/gcc-compilers/mingw-gcc12/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libtest_pb_lib.a(test.pb.obj): in function `absl::lts_20230125::log_internal::LogMessage& absl::lts_20230125::log_internal::LogMessage::operator<< <19>(char const (&) [19])':
[build] D:/ProgramFilesU/gcc-compilers/mingw-gcc12/include/absl/log/internal/log_message.h:295: undefined reference to `absl::lts_20230125::log_internal::LogMessage::CopyToEncodedBuffer(std::basic_string_view<char, std::char_traits<char> >, absl::lts_20230125::log_internal::LogMessage::StringType)'
[build] D:/ProgramFilesU/gcc-compilers/mingw-gcc12/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libtest_pb_lib.a(test.pb.obj): in function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >* absl::lts_20230125::log_internal::Check_LEImpl<int, google::protobuf::internal::EpsCopyInputStream::{unnamed type#2}>(int const&, google::protobuf::internal::EpsCopyInputStream::{unnamed type#2} const&, char const*)':
[build] D:/ProgramFilesU/gcc-compilers/mingw-gcc12/include/absl/log/internal/check_op.h:338: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >* absl::lts_20230125::log_internal::MakeCheckOpString<long long, long long>(long long, long long, char const*)'
[build] D:/ProgramFilesU/gcc-compilers/mingw-gcc12/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libtest_pb_lib.a(test.pb.obj): in function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >* absl::lts_20230125::log_internal::Check_NEImpl<test const*, test*>(test const* const&, test* const&, char const*)':
[build] D:/ProgramFilesU/gcc-compilers/mingw-gcc12/include/absl/log/internal/check_op.h:337: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >* absl::lts_20230125::log_internal::MakeCheckOpString<void const*, void const*>(void const*, void const*, char const*)'
[build] D:/ProgramFilesU/gcc-compilers/mingw-gcc12/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libtest_pb_lib.a(test.pb.obj): in function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >* absl::lts_20230125::log_internal::MakeCheckOpString<unsigned long long, long long>(unsigned long long, long long, char const*)':
[build] D:/ProgramFilesU/gcc-compilers/mingw-gcc12/include/absl/log/internal/check_op.h:292: undefined reference to `absl::lts_20230125::log_internal::CheckOpMessageBuilder::CheckOpMessageBuilder(char const*)'
[build] D:/ProgramFilesU/gcc-compilers/mingw-gcc12/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/ProgramFilesU/gcc-compilers/mingw-gcc12/include/absl/log/internal/check_op.h:294: undefined reference to `absl::lts_20230125::log_internal::CheckOpMessageBuilder::ForVar2()'
[build] D:/ProgramFilesU/gcc-compilers/mingw-gcc12/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/ProgramFilesU/gcc-compilers/mingw-gcc12/include/absl/log/internal/check_op.h:295: undefined reference to `absl::lts_20230125::log_internal::CheckOpMessageBuilder::NewString[abi:cxx11]()'
[build] collect2.exe: error: ld returned 1 exit status
[build] ninja: build stopped: subcommand failed.
[proc] The command: D:\ProgramFiles\CMake\bin\cmake.EXE --build d:/Git/build-learnProtobuf-win --config Debug --target all --parallel -- exited with code: 1
[build] Build finished with exit code 1

It seems that many functions defined in absl::lts_20230125 can not be found by the linker.

Anything else we should know about your project / environment

Version of my cmake: 3.26.0-rc6

ABSL is not installed before I configure protobuf, so it must be installed together with protobuf.

The command used to clone protobuf repo:

git clone --recursive https://github.com/protocolbuffers/protobuf.git

The command used to configure protobuf:

cmake -S . -B ../build -G Ninja -DCMAKE_CXX_COMPILER:FILEPATH=D:\ProgramFilesU\gcc-compilers\mingw-gcc12\bin\g++.exe -DCMAKE_C_COMPILER:FILEPATH=D:\ProgramFilesU\gcc-compilers\mingw-gcc12\bin\gcc.exe -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=D:\ProgramFilesU\gcc-compilers\mingw-gcc12\bin
@ToKiNoBug ToKiNoBug added the untriaged auto added to all issues by default when created. label Mar 21, 2023
@anandolee anandolee added the c++ label Mar 28, 2023
@anandolee anandolee removed the untriaged auto added to all issues by default when created. label Mar 28, 2023
@mkruskal-google
Copy link
Member

This signals that our Abseil dependency isn't being properly linked in. If you have a system installation at the wrong version that could explain it

@ToKiNoBug
Copy link
Author

This signals that our Abseil dependency isn't being properly linked in. If you have a system installation at the wrong version that could explain it

I'm sorry but I have only one protobuf, it is installed at the compiler's prefix. So find_package must have found the correct one, but some absl libs are not linked to my executable. I have tried manually adding many absl libs links to executable, but I still failed. Do you know which library in absl should be linked?

@jonaski
Copy link
Contributor

jonaski commented Apr 23, 2023

I can confirm this issue. getting abseil log related linking issues with both MinGW and Visual Studio 2022.
I worked around it with by manually specifying the abseil libraries in target_link_libraries, see: https://github.com/strawberrymusicplayer/strawberry/blob/69658f20222a2f87af3b025032def7b35730f76d/ext/libstrawberry-tagreader/CMakeLists.txt#L53

Here is the linking issue with Visual Studio 2022:

Severity	Code	Description	Project	File	Line	Suppression State
Error	LNK2019	unresolved external symbol "public: __cdecl absl::lts_20230125::log_internal::LogMessageFatal::LogMessageFatal(char const *,int,class absl::lts_20230125::string_view)" (??0LogMessageFatal@log_internal@lts_20230125@absl@@QEAA@PEBDHVstring_view@23@@Z) referenced in function "public: bool __cdecl spb::tagreader::Message::has_is_media_file_request(void)const " (?has_is_media_file_request@Message@tagreader@spb@@QEBA_NXZ)	C:\Data\Projects\strawberry\strawberry\out\build\x64-debug\strawberry	C:\Data\Projects\strawberry\strawberry\out\build\x64-debug\tagreaderworker.cpp.obj	1	
Error	LNK2001	unresolved external symbol "public: __cdecl absl::lts_20230125::log_internal::LogMessageFatal::LogMessageFatal(char const *,int,class absl::lts_20230125::string_view)" (??0LogMessageFatal@log_internal@lts_20230125@absl@@QEAA@PEBDHVstring_view@23@@Z)	C:\Data\Projects\strawberry\strawberry\out\build\x64-debug\strawberry	C:\Data\Projects\strawberry\strawberry\out\build\x64-debug\libstrawberry-tagreader.lib(tagreadermessages.pb.cc.obj)	1	
Error	LNK2019	unresolved external symbol "public: __cdecl absl::lts_20230125::log_internal::LogMessageFatal::~LogMessageFatal(void)" (??1LogMessageFatal@log_internal@lts_20230125@absl@@QEAA@XZ) referenced in function "public: bool __cdecl spb::tagreader::Message::has_is_media_file_request(void)const " (?has_is_media_file_request@Message@tagreader@spb@@QEBA_NXZ)	C:\Data\Projects\strawberry\strawberry\out\build\x64-debug\strawberry	C:\Data\Projects\strawberry\strawberry\out\build\x64-debug\tagreaderworker.cpp.obj	1	
Error	LNK2001	unresolved external symbol "public: __cdecl absl::lts_20230125::log_internal::LogMessageFatal::~LogMessageFatal(void)" (??1LogMessageFatal@log_internal@lts_20230125@absl@@QEAA@XZ)	C:\Data\Projects\strawberry\strawberry\out\build\x64-debug\strawberry	C:\Data\Projects\strawberry\strawberry\out\build\x64-debug\libstrawberry-tagreader.lib(tagreadermessages.pb.cc.obj)	1	
Error	LNK2019	unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * __cdecl absl::lts_20230125::log_internal::MakeCheckOpString<void const *,void const *>(void const *,void const *,char const *)" (??$MakeCheckOpString@PEBXPEBX@log_internal@lts_20230125@absl@@YAPEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PEBX0PEBD@Z) referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * __cdecl absl::lts_20230125::log_internal::Check_NEImpl<class spb::tagreader::IsMediaFileRequest const *,class spb::tagreader::IsMediaFileRequest *>(class spb::tagreader::IsMediaFileRequest const * const &,class spb::tagreader::IsMediaFileRequest * const &,char const *)" (??$Check_NEImpl@PEBVIsMediaFileRequest@tagreader@spb@@PEAV123@@log_internal@lts_20230125@absl@@YAPEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBQEBVIsMediaFileRequest@tagreader@spb@@AEBQEAV567@PEBD@Z)	C:\Data\Projects\strawberry\strawberry\out\build\x64-debug\strawberry	C:\Data\Projects\strawberry\strawberry\out\build\x64-debug\libstrawberry-tagreader.lib(tagreadermessages.pb.cc.obj)	1	
Error	LNK1120	3 unresolved externals	C:\Data\Projects\strawberry\strawberry\out\build\x64-debug\strawberry	C:\Data\Projects\strawberry\strawberry\out\build\x64-debug\strawberry-tagreader.exe	1	

Here is how I build protobuf with abseil for Visual Studio:
https://github.com/strawberrymusicplayer/strawberry-msvc/blob/5f4f9a33193b051a97e19a16eee32b47b961d049/build.bat#L1288
Similar in GitHub Actions:
https://github.com/strawberrymusicplayer/strawberry-msvc-dependencies/blob/643245abdd06f90e433d5134dce8aafcc1fc6d0c/.github/workflows/build.yml#L2308
I use -Dprotobuf_ABSL_PROVIDER="module"

For MinGW I build Protobuf with -Dprotobuf_ABSL_PROVIDER='package'.

@ToKiNoBug
Copy link
Author

ToKiNoBug commented Apr 24, 2023

I can confirm this issue. getting abseil log related linking issues with both MinGW and Visual Studio 2022. I worked around it with by manually specifying the abseil libraries in target_link_libraries, see: https://github.com/strawberrymusicplayer/strawberry/blob/69658f20222a2f87af3b025032def7b35730f76d/ext/libstrawberry-tagreader/CMakeLists.txt#L53

Here is the linking issue with Visual Studio 2022:

Severity	Code	Description	Project	File	Line	Suppression State
Error	LNK2019	unresolved external symbol "public: __cdecl absl::lts_20230125::log_internal::LogMessageFatal::LogMessageFatal(char const *,int,class absl::lts_20230125::string_view)" (??0LogMessageFatal@log_internal@lts_20230125@absl@@QEAA@PEBDHVstring_view@23@@Z) referenced in function "public: bool __cdecl spb::tagreader::Message::has_is_media_file_request(void)const " (?has_is_media_file_request@Message@tagreader@spb@@QEBA_NXZ)	C:\Data\Projects\strawberry\strawberry\out\build\x64-debug\strawberry	C:\Data\Projects\strawberry\strawberry\out\build\x64-debug\tagreaderworker.cpp.obj	1	
Error	LNK2001	unresolved external symbol "public: __cdecl absl::lts_20230125::log_internal::LogMessageFatal::LogMessageFatal(char const *,int,class absl::lts_20230125::string_view)" (??0LogMessageFatal@log_internal@lts_20230125@absl@@QEAA@PEBDHVstring_view@23@@Z)	C:\Data\Projects\strawberry\strawberry\out\build\x64-debug\strawberry	C:\Data\Projects\strawberry\strawberry\out\build\x64-debug\libstrawberry-tagreader.lib(tagreadermessages.pb.cc.obj)	1	
Error	LNK2019	unresolved external symbol "public: __cdecl absl::lts_20230125::log_internal::LogMessageFatal::~LogMessageFatal(void)" (??1LogMessageFatal@log_internal@lts_20230125@absl@@QEAA@XZ) referenced in function "public: bool __cdecl spb::tagreader::Message::has_is_media_file_request(void)const " (?has_is_media_file_request@Message@tagreader@spb@@QEBA_NXZ)	C:\Data\Projects\strawberry\strawberry\out\build\x64-debug\strawberry	C:\Data\Projects\strawberry\strawberry\out\build\x64-debug\tagreaderworker.cpp.obj	1	
Error	LNK2001	unresolved external symbol "public: __cdecl absl::lts_20230125::log_internal::LogMessageFatal::~LogMessageFatal(void)" (??1LogMessageFatal@log_internal@lts_20230125@absl@@QEAA@XZ)	C:\Data\Projects\strawberry\strawberry\out\build\x64-debug\strawberry	C:\Data\Projects\strawberry\strawberry\out\build\x64-debug\libstrawberry-tagreader.lib(tagreadermessages.pb.cc.obj)	1	
Error	LNK2019	unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * __cdecl absl::lts_20230125::log_internal::MakeCheckOpString<void const *,void const *>(void const *,void const *,char const *)" (??$MakeCheckOpString@PEBXPEBX@log_internal@lts_20230125@absl@@YAPEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PEBX0PEBD@Z) referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * __cdecl absl::lts_20230125::log_internal::Check_NEImpl<class spb::tagreader::IsMediaFileRequest const *,class spb::tagreader::IsMediaFileRequest *>(class spb::tagreader::IsMediaFileRequest const * const &,class spb::tagreader::IsMediaFileRequest * const &,char const *)" (??$Check_NEImpl@PEBVIsMediaFileRequest@tagreader@spb@@PEAV123@@log_internal@lts_20230125@absl@@YAPEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBQEBVIsMediaFileRequest@tagreader@spb@@AEBQEAV567@PEBD@Z)	C:\Data\Projects\strawberry\strawberry\out\build\x64-debug\strawberry	C:\Data\Projects\strawberry\strawberry\out\build\x64-debug\libstrawberry-tagreader.lib(tagreadermessages.pb.cc.obj)	1	
Error	LNK1120	3 unresolved externals	C:\Data\Projects\strawberry\strawberry\out\build\x64-debug\strawberry	C:\Data\Projects\strawberry\strawberry\out\build\x64-debug\strawberry-tagreader.exe	1	

Here is how I build protobuf with abseil for Visual Studio: https://github.com/strawberrymusicplayer/strawberry-msvc/blob/5f4f9a33193b051a97e19a16eee32b47b961d049/build.bat#L1288 Similar in GitHub Actions: https://github.com/strawberrymusicplayer/strawberry-msvc-dependencies/blob/643245abdd06f90e433d5134dce8aafcc1fc6d0c/.github/workflows/build.yml#L2308 I use -Dprotobuf_ABSL_PROVIDER="module"

For MinGW I build Protobuf with -Dprotobuf_ABSL_PROVIDER='package'.

Thanks! I'm glad to see that I'm not the only one who meets this weird issue.

Your code implies that developer should link absl_log_internal_message absl_log_internal_check_op or abseil_dll manually. I think it is some kind of bug in protobuf's cmake script, because users have to learn a lot of abseil before learning protobuf.
I suppose that required abseil libs should be linked publicly instead of privately.

@mkruskal-google
Copy link
Member

Our Abseil dependency is public, so I'm not sure why it isn't getting pulled in transitively. Both of the cmake targets you mentioned are new to Abseil's latest LTS release (20230125.2). This tells me that you have an older version of Abseil installed on your system that's missing these libraries. Setting -Dprotobuf_ABSL_PROVIDER='package' forces the protobuf build to search for system installations of Abseil, rather than the pinned sub-module we provide

@jonaski
Copy link
Contributor

jonaski commented Apr 25, 2023

There isn't any older abseil version installed. I'm getting similar log_internal related linking errors in 4 places including cross-compiling on Linux, a clean Windows 10 MSVC physical machine, github actions both MSVC and MinGW cross-compilation, cross-compiling on my own linux machine . Setting protobuf_ABSL_PROVIDER to module doesn't help.
I don't use protobuf from git, but compile the latest release, it has just an empty third_party/abseil-cpp/ directory, so I copy over the latest version (20230125.2).

@mkruskal-google
Copy link
Member

hmm lemme see if I can try to reproduce this then. We test against MSVC in our CI, so I'm not sure what the issue could be here

@jonaski
Copy link
Contributor

jonaski commented Apr 25, 2023

Just to clarify, the linking errors does not occur when compiling protobuf itself, but occurs when compiling my own program with protobuf, so the linker flags for the abseil libraries aren't passed on for some reason, I spent a few hours looking into it, but could not figure it out.

@mkruskal-google
Copy link
Member

Can you provide the commands you use to build and install protobuf too? Also, do the missing targets end up in the installation lib directory?

@mxito3
Copy link

mxito3 commented Apr 27, 2023

Same issue here.

I am build protobuffer for android.

my commands

  • unzip protobuf-22.3.zip
  • cd protobuf-22.3
  • mkdir build && cd build
  • cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DANDROID_STL=c++_static -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-29 -DCMAKE_TOOLCHAIN_FILE=${NDK}/build/cmake/android.toolchain.cmake -Dprotobuf_BUILD_LIBPROTOC=OFF -Dprotobuf_BUILD_TESTS=OFF ..
  • cmake --build . -v

Error

ld: error: undefined symbol: absl::lts_20230125::Mutex::~Mutex()

referenced by generated_message_reflection.cc:3447 (/opt/protobuf-22.3/src/google/protobuf/generated_message_reflection.cc:3447)
generated_message_reflection.cc.o:(google::protobuf::(anonymous namespace)::AssignDescriptorsImpl(google::protobuf::internal::DescriptorTable const*, bool)) in archive /opt/protobuf-22.3/build/libprotobuf.a
referenced by generated_message_reflection.cc:3447 (/opt/protobuf-22.3/src/google/protobuf/generated_message_reflection.cc:3447)
generated_message_reflection.cc.o:(google::protobuf::(anonymous namespace)::AssignDescriptorsImpl(google::protobuf::internal::DescriptorTable const*, bool)) in archive /opt/protobuf-22.3/build/libprotobuf.a
referenced by generated_message_reflection.cc:3420 (/opt/protobuf-22.3/src/google/protobuf/generated_message_reflection.cc:3420)
generated_message_reflection.cc.o:(google::protobuf::(anonymous namespace)::MetadataOwner* google::protobuf::internal::OnShutdownDelete<google::protobuf::(anonymous namespace)::MetadataOwner>(google::protobuf::(anonymous namespace)::MetadataOwner*)::'lambda'(void const*)::__invoke(void const*)) in archive /opt/protobuf-22.3/build/libprotobuf.a
referenced 9 more times

ld: error: undefined symbol: absl::lts_20230125::base_internal::SpinLockWait(std::__ndk1::atomic, int, absl::lts_20230125::base_internal::SpinLockWaitTransition const, absl::lts_20230125::base_internal::SchedulingMode)

@coryan
Copy link
Contributor

coryan commented May 1, 2023

I believe the issue is that something like find_package(protobuf REQUIRED) uses the embedded FindProtobuf package from CMake:

https://cmake.org/cmake/help/latest/module/FindProtobuf.html

This package has not been updated to know about the Abseil dependency. One needs to use:

find_package(protobuf REQUIRED CONFIG)

@mkruskal-google
Copy link
Member

Hah thank you Carlos! That perfectly explains why our examples directory is building ok but this one isn't :)

@ibc
Copy link

ibc commented May 17, 2023

Not sure if related, but we are having same problem (tons of undefined reference to absl::lts_20230125::crc_internal::xxxxx`) in our project which uses Meson to build C++ and abseil-cpp dep using C++17:

versatica/mediasoup#1081 (comment)

@mkruskal-google
Copy link
Member

Sounds related, the fix here was to specify CONFIG on the find_package call for protobuf. The FindProtobuf function that ships with CMake doesn't include our new dependency on Abseil

sighingnow added a commit to sighingnow/etcd-cpp-apiv3 that referenced this issue Jun 15, 2023
sighingnow added a commit to sighingnow/GraphScope that referenced this issue Jun 15, 2023
@jonaski
Copy link
Contributor

jonaski commented Aug 8, 2023

@harsh-im
Your CMakeLists looks fine as far as I can tell, and I don't think those abseil related linking issues are related to this issue, there are no abseil log related errors from what you pasted. As far as I know ubuntu:latest is currently using Jammy (22.04), which is using an much older version of Protobuf (3.12.4), which is before Protobuf started using abseil log.
The linking issues you have might be an ubuntu bug, perhaps a mismatch between abseil libraries and protobuf libraries. Did you run apt update and apt upgrade and see if it helps?

@harsh-im
Copy link

harsh-im commented Aug 8, 2023

@jonaski I have built grpc along with its third party dependencies referring :https://github.com/grpc/grpc/blob/master/BUILDING.md#building-with-cmake
and I have copied the build in docker container and I am specifying grpc build path in -DCMAKE_PREFIX_PATH

@onocpj
Copy link

onocpj commented Aug 9, 2023

You can pass -DCMAKE_FIND_PACKAGE_PREFER_CONFIG to cmake and it will use "Config" first.

Otherwise use the following so it's compatible with older versions of Protobuf too.

find_package(Protobuf CONFIG)
if(NOT Protobuf_FOUND)
  find_package(Protobuf REQUIRED)
endif()

For the library use protobuf::libprotobuf, for the executable use protobuf::protoc. But I think variables for include and library dirs are not set.

There was also a bug in protobuf-generate.cmake (#12450) Can be worked around it with:

if(NOT protobuf_PROTOC_EXE)
  set(protobuf_PROTOC_EXE "protobuf::protoc")
endif()

Thanks, worked for me after I have combined solutions (version 23.4):

  1. Using following options in cmake
    -Dprotobuf_BUILD_TESTS=OFF -DABSL_BUILD_TESTING=OFF -DABSL_USE_GOOGLETEST_HEAD=OFF -DABSL_PROPAGATE_CXX_STD=ON -DCMAKE_CXX_STANDARD=17

Full example:

$ git clone https://github.com/protocolbuffers/protobuf.git --branch v23.4  --single-branch protobuf-23.4
$ cd protobuf-23.4
$ git submodule update --init --recursive
$ cmake -Dprotobuf_BUILD_TESTS=OFF -DABSL_BUILD_TESTING=OFF -DABSL_USE_GOOGLETEST_HEAD=OFF -DABSL_PROPAGATE_CXX_STD=ON -DCMAKE_CXX_STANDARD=17 .
$ make
$ make install
  1. Added following in CMakeLists.txt
find_package(Protobuf CONFIG)
if(NOT Protobuf_FOUND)
  find_package(Protobuf REQUIRED)
endif()
  1. Linked protobuf::libprotobuf to library

@harsh-im
Copy link

You can pass -DCMAKE_FIND_PACKAGE_PREFER_CONFIG to cmake and it will use "Config" first.
Otherwise use the following so it's compatible with older versions of Protobuf too.

find_package(Protobuf CONFIG)
if(NOT Protobuf_FOUND)
  find_package(Protobuf REQUIRED)
endif()

For the library use protobuf::libprotobuf, for the executable use protobuf::protoc. But I think variables for include and library dirs are not set.
There was also a bug in protobuf-generate.cmake (#12450) Can be worked around it with:

if(NOT protobuf_PROTOC_EXE)
  set(protobuf_PROTOC_EXE "protobuf::protoc")
endif()

Thanks, worked for me after I have combined solutions (version 23.4):

  1. Using following options in cmake
    -Dprotobuf_BUILD_TESTS=OFF -DABSL_BUILD_TESTING=OFF -DABSL_USE_GOOGLETEST_HEAD=OFF -DABSL_PROPAGATE_CXX_STD=ON -DCMAKE_CXX_STANDARD=17

Full example:

$ git clone https://github.com/protocolbuffers/protobuf.git --branch v23.4  --single-branch protobuf-23.4
$ cd protobuf-23.4
$ git submodule update --init --recursive
$ cmake -Dprotobuf_BUILD_TESTS=OFF -DABSL_BUILD_TESTING=OFF -DABSL_USE_GOOGLETEST_HEAD=OFF -DABSL_PROPAGATE_CXX_STD=ON -DCMAKE_CXX_STANDARD=17 .
$ make
$ make install
  1. Added following in CMakeLists.txt
find_package(Protobuf CONFIG)
if(NOT Protobuf_FOUND)
  find_package(Protobuf REQUIRED)
endif()
  1. Linked protobuf::libprotobuf to library

@onocpj Hey, I have tried following your mentioned steps but I am still getting the following errors

[ 83%] Linking CXX executable test_nativelib
nativelib.so: undefined reference to `absl::lts_20230125::log_internal::LogMessage::CopyToEncodedBuffer(absl::lts_20230125::string_view, absl::lts_20230125::log_internal::LogMessage::StringType)'

nativelib.so: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(absl::lts_20230125::string_view, google::protobuf::Arena*)'

nativelib.so: undefined reference to `absl::lts_20230125::cord_internal::InitializeCordRepExternal(absl::lts_20230125::string_view, absl::lts_20230125::cord_internal::CordRepExternal*)'

jkhsjdhjs added a commit to jkhsjdhjs/p4c that referenced this issue Aug 12, 2023
Google introduced abseil as a new dependency of Protobuf, but CMake's
FindProtobuf hasn't been updated yet to link with abseil. Thus, CMake is
now advised to use the config provided by Protobuf instead of its own.
In case no config can be found, we fall back to the old behavior.

The Protobuf version constraint is removed since it only applies with
`P4C_USE_PREINSTALLED_PROTOBUF=ON` anyway, in which case we'll want to
use whatever preinstalled version is available.

Furthermore, the variables `PROTOBUF_LIBRARY` and
`PROTOBUF_PROTOC_EXECUTABLE` are set correctly so executing `protoc` and
linking with Protobuf doesn't fail.

Fix p4lang#4055
See also protocolbuffers/protobuf#12292
fruffy pushed a commit to p4lang/p4c that referenced this issue Aug 24, 2023
Google introduced abseil as a new dependency of Protobuf, but CMake's
FindProtobuf hasn't been updated yet to link with abseil. Thus, CMake is
now advised to use the config provided by Protobuf instead of its own.
In case no config can be found, we fall back to the old behavior.

The Protobuf version constraint is removed since it only applies with
`P4C_USE_PREINSTALLED_PROTOBUF=ON` anyway, in which case we'll want to
use whatever preinstalled version is available.

Furthermore, the variables `PROTOBUF_LIBRARY` and
`PROTOBUF_PROTOC_EXECUTABLE` are set correctly so executing `protoc` and
linking with Protobuf doesn't fail.

Fix #4055
See also protocolbuffers/protobuf#12292
@dailylama
Copy link

dailylama commented Oct 9, 2023

hello, I'm following this

https://github.com/protocolbuffers/protobuf/blob/main/docs/cmake_protobuf_generate.md

target_link_libraries(proto-objects PUBLIC protobuf::libprotobuf)

ld: error: undefined symbol: absl::lts_20230125::log_internal::LogMessageFatal::LogMessageFatal(char const*, int, std::__ndk1::basic_string_view<char, std::__ndk1::char_traits<char> >)
>>> referenced by arena_align.h:180 (protobuf/src/google/protobuf/arena_align.h:180)
>>>               CMakeFiles/dir/sample.pb.cc.o:(google::protobuf::internal::ArenaAlignAs(unsigned long))
>>> referenced by arena_align.h:181 (protobuf/src/google/protobuf/arena_align.h:181)
>>>               CMakeFiles/dir/sample.pb.cc.o:(google::protobuf::internal::ArenaAlignAs(unsigned long))

am I missing something? If so, please update file at the link

@DDDDarcy
Copy link

I have same issue

@pascaldekloe
Copy link

Compiling with -labsl_log_internal_message -labsl_log_internal_check_op -std=c++17 resolved the issue for me.

@bach001
Copy link

bach001 commented Nov 2, 2023

Seems that this issue was caused by the fact that the relevant Protobuf_* variables are empty, even find_package return Protobuf_FOUND=true. related issue

Have struggled days to solve this issue and found 2 solutions.

#1 set protobuf_MODULE_COMPATIBLE variable mentioned in the above link.

set(protobuf_MODULE_COMPATIBLE true)

#2 Issuing double calls to find_package()

find_package(Protobuf CONFIG)
find_package(Protobuf REQUIRED)

In my case, both work on linux and windows.

@nharis7
Copy link

nharis7 commented Nov 21, 2023

Sorry for stupid questions, but I am pretty new to protobuf and abseil. I am getting the same linker errors for my own project. I am using MSVC 17 2022 Windows 11 and I do not have cmakelists.txt file in my project. So, I am stuck here from last few weeks. Would be greatful if someone can help me in getting it fixed.

Error	LNK2001	unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * __cdecl absl::log_internal::MakeCheckOpString<unsigned __int64,unsigned __int64>(unsigned __int64,unsigned __int64,char const *)" (??$MakeCheckOpString@_K_K@log_internal@absl@@YAPEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_K0PEBD@Z)

Error	LNK2001	unresolved external symbol "public: __cdecl absl::log_internal::LogMessageFatal::~LogMessageFatal(void)" (??1LogMessageFatal@log_internal@absl@@QEAA@XZ)	..ONNX\libprotobuf.lib(zero_copy_stream_impl.obj)

Error	LNK2001	unresolved external symbol "public: __cdecl absl::log_internal::LogMessageFatal::LogMessageFatal(char const *,int,class absl::string_view)" (??0LogMessageFatal@log_internal@absl@@QEAA@PEBDHVstring_view@2@@Z)	..\ONNX\libprotobuf.lib(zero_copy_stream_impl_lite.obj)

I did not post alloff the errors but they are related to absl.

@loicfar
Copy link

loicfar commented Dec 15, 2023

I believe the issue is that something like find_package(protobuf REQUIRED) uses the embedded FindProtobuf package from CMake:

https://cmake.org/cmake/help/latest/module/FindProtobuf.html

This package has not been updated to know about the Abseil dependency. One needs to use:

find_package(protobuf REQUIRED CONFIG)

This still doesn't do it for me. My cmake file is like this:

set(PROTOBUF ${THIRD_PARTY}/protobuf) # My personal protobuf dir
set(Protobuf_INCLUDE_DIRS ${PROTOBUF}/include)

set(absl_DIR ${PROTOBUF}/lib/cmake/absl)
set(utf8_range_DIR ${PROTOBUF}/lib/cmake/utf8_range)

find_package(protobuf CONFIG REQUIRED HINTS ${PROTOBUF})

Still get all the linker issues like:

  • Error LNK2001 unresolved external symbol "void __cdecl google::protobuf::internal::protobuf_assumption_failed(char const *,char const *,int)" (?protobuf_assumption_failed@internal@protobuf@google@@YAXPEBD0H@Z) io C:\dev\velta\solution\projects\io\context.obj 1
  • Error LNK2001 unresolved external symbol "public: class absl::lts_20230802::log_internal::LogMessage & __cdecl absl::lts_20230802::log_internal::LogMessage::operator<<<unsigned __int64,0>(unsigned __int64 const &)" (??$?6_K$0A@@LogMessage@log_internal@lts_20230802@absl@@QEAAAEAV0123@AEB_K@Z) io C:\dev\velta\solution\projects\io\io.pb.obj 1
  • Error LNK2001 unresolved external symbol "private: void __cdecl absl::lts_20230802::log_internal::LogMessage::CopyToEncodedBuffer<0>(class absl::lts_20230802::string_view)" (??$CopyToEncodedBuffer@$0A@@LogMessage@log_internal@lts_20230802@absl@@AEAAXVstring_view@23@@Z) io C:\dev\velta\solution\projects\io\inputs.pb.obj 1
  • Error LNK2001 unresolved external symbol "public: __cdecl absl::lts_20230802::log_internal::LogMessageFatal::LogMessageFatal(char const *,int,class absl::lts_20230802::string_view)" (??0LogMessageFatal@log_internal@lts_20230802@absl@@QEAA@PEBDHVstring_view@23@@Z) io C:\dev\velta\solution\projects\io\pricers.pb.obj 1
  • ...

@6r0m
Copy link

6r0m commented Dec 27, 2023

I had the same errors with integration gRPC (1.59.3) build on Windows, which depends on abseil and protobuf (4.24.3) as well.

finally solved with abseil specific flags:
cmake ../../PublicRepos/grpc/grpc -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="G:/Build/grpc/install" -DgRPC_SSL_PROVIDER=package -DOPENSSL_ROOT_DIR="C:/Program Files/OpenSSL" -DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON -DABSL_PROPAGATE_CXX_STD=ON -Dprotobuf_ABSL_PROVIDER=package -DCMAKE_PREFIX_PATH="G:\PublicRepos\grpc\grpc\third_party\abseil-cpp\absl" -DCMAKE_CXX_STANDARD=17 -Dprotobuf_BUILD_TESTS=OFF

@y-code
Copy link

y-code commented Feb 1, 2024

I got the same error during building my code using protobuf 3.21.

The approach @pascaldekloe left in his comment above worked for me, where I use c++20.

In CMakeLists.txt,

find_package( absl REQUIRED )
find_package( Protobuf 3.21 REQUIRED )
# ...
target_link_libraries(
    ${Protobuf_LIBRARIES}
    absl::log_internal_message
    absl::log_internal_check_op
)

No cmake variable set was required.

ashay added a commit to ashay/torch-mlir that referenced this issue Feb 12, 2024
This patch makes the Protobuf package mandatory in addition to forcing a
config mode search.  The (default) module mode search looks for the
CMake-provided FindProtobuf.cmake file, but this file does not list
Abseil as a dependency, causing linker issues like the one below:

```
ld: Undefined symbols:
  absl::lts_20230802::log_internal::LogMessageFatal::LogMessageFatal(char const*, int, std::__1::basic_string_view<char, std::__1::char_traits<char>>), referenced from:
      google::protobuf::RepeatedPtrField<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>::TypeHandler::Type const& google::protobuf::internal::RepeatedPtrFieldBase::Get<google::protobuf::RepeatedPtrField<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>::TypeHandler>(int) const (.cold.1) in OnnxImporter.cpp.o
```

By forcing a config mode search, CMake looks for the file that is
installed as part of the protobuf package and which does contain the
Abseil dependency.  This workaround is also mentioned in a GitHub issue
for Protobuf:
protocolbuffers/protobuf#12292 (comment).
ashay added a commit to llvm/torch-mlir that referenced this issue Feb 12, 2024
This patch makes the Protobuf package mandatory in addition to forcing a
config mode search.  The (default) module mode search looks for the
CMake-provided FindProtobuf.cmake file, but this file does not list
Abseil as a dependency, causing linker issues like the one below:

```
ld: Undefined symbols:
  absl::lts_20230802::log_internal::LogMessageFatal::LogMessageFatal(char const*, int, std::__1::basic_string_view<char, std::__1::char_traits<char>>), referenced from:
      google::protobuf::RepeatedPtrField<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>::TypeHandler::Type const& google::protobuf::internal::RepeatedPtrFieldBase::Get<google::protobuf::RepeatedPtrField<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>::TypeHandler>(int) const (.cold.1) in OnnxImporter.cpp.o
```

By forcing a config mode search, CMake looks for the file that is
installed as part of the protobuf package and which does contain the
Abseil dependency.  This workaround is also mentioned in a GitHub issue
for Protobuf:
protocolbuffers/protobuf#12292 (comment).
@adokhugi
Copy link

adokhugi commented Apr 5, 2024

I'm compiling the code of a program I downloaded from GitHub that employs emscripten and protobuf v25.3 for Windows 11 using this command line:

emcc -O2 -I. -I./eigen/ -Ic:/projects/soft/protobuf/src -Ic:/projects/soft/abseil-cpp libabsl_base.a libabsl_log_severity.a libabsl_malloc_internal.a libabsl_raw_logging_internal.a libabsl_scoped_set_env.a libabsl_spinlock_wait.a libabsl_strerror.a libabsl_throw_delegate.a libabsl_die_if_null.a libabsl_log_entry.a libabsl_city.a libabsl_hash.a libabsl_log_globals.a libabsl_log_flags.a libabsl_log_initialize.a libabsl_log_internal_conditions.a libabsl_log_internal_fnmatch.a libabsl_log_internal_globals.a libabsl_log_internal_nullguard.a libabsl_log_internal_proto.a libabsl_log_sink.a libabsl_int128.a libabsl_time_zone.a libabsl_time.a libabsl_kernel_timeout_internal.a libabsl_graphcycles_internal.a libabsl_stacktrace.a libabsl_symbolize.a libabsl_synchronization.a libabsl_log_internal_log_sink_set.a libabsl_str_format_internal.a libabsl_strings_internal.a libabsl_strings.a libabsl_string_view.a libabsl_log_internal_format.a libabsl_examine_stack.a libabsl_log_internal_message.a libabsl_die_if_null.a libabsl_log_internal_check_op.a libabsl_vlog_config_internal.a libabsl_cord.a libabsl_crc_cord_state.a libabsl_cord_internal.a libabsl_crc32c.a libabsl_flags_commandlineflag.a libabsl_flags_config.a libabsl_flags_internal.a libabsl_flags_marshalling.a libabsl_flags_parse.a libabsl_flags_private_handle_accessor.a libabsl_flags_program_name.a libabsl_flags_reflection.a libabsl_flags_usage.a libabsl_flags_usage_internal.a libabsl_log_internal_check_op.a libabsl_log_internal_fnmatch.a libabsl_log_internal_format.a libabsl_log_internal_globals.a libabsl_log_internal_log_sink_set.a libabsl_log_internal_message.a libabsl_random_internal_distribution_test_util.a libabsl_status.a libabsl_statusor.a libabsl_cordz_handle.a libabsl_cordz_info.a libabsl_crc_internal.a libabsl_failure_signal_handler.a libabsl_hashtablez_sampler.a libabsl_random_internal_pool_urbg.a libabsl_bad_any_cast_impl.a libabsl_bad_optional_access.a libabsl_bad_variant_access.a libabsl_civil_time.a libabsl_cordz_functions.a libabsl_cordz_sample_token.a libabsl_crc_cpu_detect.a libabsl_debugging_internal.a libabsl_demangle_internal.a libabsl_exponential_biased.a libabsl_flags.a libabsl_flags_commandlineflag_internal.a libabsl_leak_check.a libabsl_low_level_hash.a libabsl_periodic_sampler.a libabsl_random_distributions.a libabsl_random_internal_platform.a libabsl_random_internal_randen.a libabsl_random_internal_randen_hwaes.a libabsl_random_internal_randen_hwaes_impl.a libabsl_random_internal_randen_slow.a libabsl_random_internal_seed_material.a libabsl_random_seed_gen_exception.a libabsl_random_seed_sequences.a libabsl_raw_hash_set.a libgmock.a libgmock_main.a libupb.a libprotobuf.a libprotoc.a crtbegin.o libal.a libbulkmemory.a libc++-noexcept.a libc++abi-noexcept.a libc.a libcompiler_rt.a libdlmalloc.a libfetch.a libGL-getprocaddr.a libhtml5.a libnoexit.a libSDL2.a libsockets.a libstubs-debug.a libstubs.a crn/crn.o -s USE_SDL=2 -Iinclude main.cpp -o main.html

I've worked on this for several hours. It turned out that the order of the '.a' files had a great impact on the error messages I received. Anyway, now most of the error messages I initially had are gone and the remaining ones are in the kind of:

wasm-ld: error: libprotobuf.a(descriptor.cc.o): undefined symbol: absl::lts_20230802::log_internal::LogMessageFatal::LogMessageFatal(char const*, int, absl::lts_20230802::string_view)

And that puzzles me because I've included all '.a' files from abseil and linked libprotobuf.a after them. So what's wrong? I suspect it's related to string_view but I might err.

After some consideration I think that maybe the wrong version of abseil is used because if I use a different version of libprotobuf.a, the error message also includes a different version date for abseil.

@give-it-a-try-1
Copy link

I also encountered this problem when using grpc, and I found a solution that worked for me on stackoverflow

Original text:
After puzzling another I found the real problem: I had protoc and protobuf already installed in Linux before I compiled GRPC. In that case GRPC decides that PROTOBUF does not need to compile again. But the change is big that the program tries to link wrong versions of libGRPC and libprotobuf. Best is to uninstall all protobuf versions, then remove remainders of protoc, libproto* and then compile GRPC again.

Following its approach, I uninstalled all of my protobuf versions and then recompiled grpc once, under linux

Original text

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests