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 · 54 comments
Closed

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

ToKiNoBug opened this issue Mar 21, 2023 · 54 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

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

@AnnaKozlova
Copy link

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.

Hello! I think it's really useful, but I have the problem there:

 (target_link_libraries):
  IMPORTED library can only be used with the INTERFACE keyword of
  target_link_libraries

Maybe someone has already encountered this and knows the solution

@MaoZiming
Copy link

MaoZiming commented Aug 5, 2024

Still getting a lot of absl reference errors after

find_package(protobuf CONFIG REQUIRED)
find_package(gRPC CONFIG REQUIRED)

@robinlzw
Copy link

Still getting a lot of absl reference errors after之后仍然收到很多absl引用错误

find_package(protobuf CONFIG REQUIRED)
find_package(gRPC CONFIG REQUIRED)

Have you solved this problem yet?

@loicfar
Copy link

loicfar commented Oct 25, 2024

I managed to install protobuf 28.1 on windows with VS2022:

  • Download abseil and put it in the right directory
  • From the root of the protobuf-X.XX.X\cmake source directory:
mkdir build/solution & cd build/solution
cmake -G "Visual Studio 17 2022" -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -DCMAKE_INSTALL_PREFIX=../../../../install ../.. -Dprotobuf_BUILD_TESTS=OFF
  • Open protobuf.sln
  • Build All (Ctrl+B) + Build project INSTALL (Debug + Release)
  • Modify the targets cmake files (lib/cmake/absl/abslTargets-[debug/release].cmake) to point to the rights .lib (I manually created lib/release and lib/debug folders).

Then for linkage:

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

find_package(Protobuf REQUIRED HINTS ${your_personal_protobuf_package_path})

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