gwaldron / osgearth

3D Maps for OpenSceneGraph / C++14
https://www.pelicanmapping.com/home-1/opensource
Other
1.47k stars 772 forks source link

Build issue: Undefined symbols in protobuf (seen on arm64/MacOS, MinGW) #2518

Closed linlangongzi closed 2 months ago

linlangongzi commented 4 months ago

osgEarth Version (required): latest version

[ 59%] Linking CXX shared library ../../lib/libosgEarth.dylib Undefined symbols for architecture arm64: "void absl::log_internal::LogMessage::CopyToEncodedBuffer<(absl::log_internal::LogMessage::StringType)0>(absl::string_view)", referenced from: absl::log_internal::LogMessage& absl::log_internal::LogMessage::operator<<<48>(char const (&) [48]) in vector_tile.pb.cc.o absl::log_internal::LogMessage& absl::log_internal::LogMessage::operator<<<59>(char const (&) [59]) in vector_tile.pb.cc.o absl::log_internal::LogMessage& absl::log_internal::LogMessage::operator<<<19>(char const (&) [19]) in vector_tile.pb.cc.o "absl::log_internal::LogMessage& absl::log_internal::LogMessage::operator<<<unsigned long, 0>(unsigned long const&)", referenced from: absl::log_internal::LogMessage::operator<<(unsigned long) in vector_tile.pb.cc.o "absl::log_internal::LogMessageFatal::LogMessageFatal(char const, int, absl::string_view)", referenced from: google::protobuf::internal::RepeatedPtrFieldBase::rep() in MapboxGLGlyphManager.cpp.o google::protobuf::RepeatedField::Get(int) const in MVT.cpp.o google::protobuf::RepeatedField::Get(int) const in MVT.cpp.o google::protobuf::RepeatedField::elements() const in MVT.cpp.o google::protobuf::internal::GenericTypeHandler::Type const& google::protobuf::internal::RepeatedPtrFieldBase::Get<google::protobuf::internal::GenericTypeHandler>(int) const in MVT.cpp.o google::protobuf::internal::GenericTypeHandler::Type const& google::protobuf::internal::RepeatedPtrFieldBase::Get<google::protobuf::internal::GenericTypeHandler>(int) const in MVT.cpp.o google::protobuf::internal::RepeatedPtrFieldBase::element_at(int) in MVT.cpp.o ... "absl::log_internal::LogMessageFatal::~LogMessageFatal()", referenced from: google::protobuf::internal::RepeatedPtrFieldBase::rep() in MapboxGLGlyphManager.cpp.o google::protobuf::internal::RepeatedPtrFieldBase::rep() in MapboxGLGlyphManager.cpp.o google::protobuf::RepeatedField::Get(int) const in MVT.cpp.o google::protobuf::RepeatedField::Get(int) const in MVT.cpp.o google::protobuf::RepeatedField::Get(int) const in MVT.cpp.o google::protobuf::RepeatedField::Get(int) const in MVT.cpp.o google::protobuf::RepeatedField::elements() const in MVT.cpp.o ... "std::1::basic_string<char, std::__1::char_traits, std::1::allocator> absl::log_internal::MakeCheckOpString<void const, void const>(void const, void const, char const)", referenced from: std::1::basic_string<char, std::__1::char_traits, std::1::allocator> absl::log_internal::Check_NEImpl<mapnik::vector::tile_value const, mapnik::vector::tile_value>(mapnik::vector::tile_value const const&, mapnik::vector::tile_value const&, char const) in vector_tile.pb.cc.o std::1::basic_string<char, std::__1::char_traits, std::1::allocator> absl::log_internal::Check_EQImpl<google::protobuf::Arena, google::protobuf::Arena>(google::protobuf::Arena const&, google::protobuf::Arena const&, char const) in vector_tile.pb.cc.o std::1::basic_string<char, std::__1::char_traits, std::1::allocator> absl::log_internal::Check_NEImpl<mapnik::vector::tile_feature const, mapnik::vector::tile_feature>(mapnik::vector::tile_feature const const&, mapnik::vector::tile_feature const&, char const) in vector_tile.pb.cc.o std::1::basic_string<char, std::__1::char_traits, std::1::allocator> absl::log_internal::Check_NEImpl<mapnik::vector::tile_layer const, mapnik::vector::tile_layer>(mapnik::vector::tile_layer const const&, mapnik::vector::tile_layer const&, char const) in vector_tile.pb.cc.o std::1::basic_string<char, std::__1::char_traits, std::1::allocator> absl::log_internal::Check_NEImpl<mapnik::vector::tile const, mapnik::vector::tile>(mapnik::vector::tile const const&, mapnik::vector::tile const&, char const) in vector_tile.pb.cc.o std::1::basic_string<char, std::__1::char_traits, std::1::allocator> absl::log_internal::Check_NEImpl<google::protobuf::RepeatedField const, google::protobuf::RepeatedField>(google::protobuf::RepeatedField const const&, google::protobuf::RepeatedField const&, char const) in vector_tile.pb.cc.o std::1::basic_string<char, std::__1::char_traits, std::1::allocator> absl::log_internal::Check_NEImpl<mapboxgl::glyphs::glyph const, mapboxgl::glyphs::glyph>(mapboxgl::glyphs::glyph const const&, mapboxgl::glyphs::glyph const&, char const) in glyphs.pb.cc.o ... "std::1::basic_string<char, std::__1::char_traits, std::1::allocator> absl::log_internal::MakeCheckOpString<long long, long long>(long long, long long, char const)", referenced from: std::1::basic_string<char, std::__1::char_traits, std::1::allocator> absl::log_internal::Check_GEImpl<int, int>(int const&, int const&, char const) in MVT.cpp.o std::1::basic_string<char, std::__1::char_traits, std::1::allocator> absl::log_internal::Check_LTImpl<int, int>(int const&, int const&, char const) in MVT.cpp.o std::1::basic_string<char, std::__1::char_traits, std::1::allocator> absl::log_internal::Check_GTImpl<int, int>(int const&, int const&, char const) in MVT.cpp.o std::1::basic_string<char, std::__1::char_traits, std::1::allocator> absl::log_internal::Check_EQImpl<int, int>(int const&, int const&, char const) in MVT.cpp.o "std::1::basic_string<char, std::__1::char_traits, std::1::allocator> absl::log_internal::MakeCheckOpString<unsigned long long, unsigned long long>(unsigned long long, unsigned long long, char const)", referenced from: std::1::basic_string<char, std::__1::char_traits, std::1::allocator> absl::log_internal::Check_LEImpl<unsigned long, unsigned long>(unsigned long const&, unsigned long const&, char const) in vector_tile.pb.cc.o "absl::log_internal::CheckOpMessageBuilder::ForVar2()", referenced from: std::1::basic_string<char, std::__1::char_traits, std::1::allocator> absl::log_internal::MakeCheckOpString<unsigned long long, long long>(unsigned long long, long long, char const) in vector_tile.pb.cc.o "absl::log_internal::CheckOpMessageBuilder::NewString()", referenced from: std::1::basic_string<char, std::__1::char_traits, std::1::allocator> absl::log_internal::MakeCheckOpString<unsigned long long, long long>(unsigned long long, long long, char const) in vector_tile.pb.cc.o "absl::log_internal::CheckOpMessageBuilder::CheckOpMessageBuilder(char const)", referenced from: std::1::basic_string<char, std::__1::char_traits, std::1::allocator> absl::log_internal::MakeCheckOpString<unsigned long long, long long>(unsigned long long, long long, char const) in vector_tile.pb.cc.o "google::protobuf::MessageLite::ParseFromString(absl::string_view)", referenced from: osgEarth::Util::MapboxGLGlyphManager::loadFont(osgEarth::URI const&) in MapboxGLGlyphManager.cpp.o osgEarth::MVT::readTile(std::1::basic_istream<char, std::__1::char_traits>&, osgEarth::TileKey const&, std::1::vector<osg::ref_ptr, std::__1::allocator<osg::ref_ptr>>&) in MVT.cpp.o "google::protobuf::internal::LookUpEnumValue(google::protobuf::internal::EnumEntry const, unsigned long, absl::string_view, int)", referenced from: mapnik::vector::tile_GeomType_Parse(absl::string_view, mapnik::vector::tile_GeomType*) in vector_tile.pb.cc.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: [lib/libosgEarth.3.5.0.dylib] Error 1 make[1]: [src/osgEarth/CMakeFiles/osgEarth.dir/all] Error 2 make: *** [all] Error 2

I set the build architecture to arm64 in os cmake file but still the same issue. really need help. thank you

gwaldron commented 3 months ago

We saw the same problem on the MacOS CI build. Looks like a protobuf problem. We do not have any OSX systems so we will need to rely on you and other OSX users to track this down.

shaozhihua commented 3 months ago

I have also recently been working on osgearth related projects on arm64 architecture CPU machines. I did compile successfully. But I'm not using Apple's operating system。 Good luck to you, buddy。

ComradeMashkov commented 3 months ago

Removing protobuf from external libraries while compiling helped a lot. However, there are still few errors left:

Error log ``` C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\osgEarth.dir/objects.a(Utils.cpp.obj):Utils.cpp:(.text+0x1af9): undefined reference to `__imp_SymInitialize' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\osgEarth.dir/objects.a(Utils.cpp.obj):Utils.cpp:(.text+0x1b93): undefined reference to `__imp_SymFromAddr' collect2.exe: error: ld returned 1 exit status mingw32-make[2]: *** [src\osgEarth\CMakeFiles\osgEarth.dir\build.make:5619: lib/libosgEarth.dll] Error 1 mingw32-make[1]: *** [CMakeFiles\Makefile2:1114: src/osgEarth/CMakeFiles/osgEarth.dir/all] Error 2 mingw32-make: *** [Makefile:135: all] Error 2 ```

I suggest SymInitialize() and SymFromAddr() are WinAPI functions (correct me if I am wrong), but why they doesn't link to library?

ComradeMashkov commented 3 months ago

For those who are interested in the same problem: build protobuf 3.21.10 (at least this version is fine for me), because it containts logger class. Then you have to link with dbghelp (-ldbghelp in CMake GUI libraries for CXX), this library implements SymInitialize() and SymFromAddr() functions.

linlangongzi commented 2 months ago

i removed protobuf and glew from cmake file when i compile the OSGEarth on MacOS (M2 Max chip) and i also modified the maxOS platform cmake file , and some other cmake file and also part of the code (there are compiler errors ) , it passed but due to lack of protobuf can not load openstreetmap. i did compile protobuf from source but still have similar link issue. so i skipped the protobuf. i think its mainly because of protobuf, so i close this issue