Hey having an absolutely miserable time trying to cross compile 
libphonenumber, which depends on protobuf, into a static library.

Everything compiles. But fails with undefined symbols at linking time.

this is how I'm building protobuf, on x86 with an x86 protoc that I built 
first.

file libraries/protoc 

libraries/protoc: Mach-O 64-bit executable x86_64


///////////////////////////////////////////////////////////////////


export build_dir=`pwd`/cpp-build

export darwin=darwin`uname -r`

export protoc=/usr/local/bin/protoc

export isysroot=`xcrun --sdk iphoneos --show-sdk-path`

export cflags="-Wno-unused-local-typedef -Wno-unused-function -DNDEBUG -g 
-O3 -pipe -fPIC -fcxx-exceptions"

export cxxflags="$cflags -std=c++17 -stdlib=libc++"


mkdir -p $build_dir/arch

mkdir -p $build_dir/lib


./configure \

--build=x86_64-apple-$darwin \

--host=arm \

--with-protoc=$protoc \

--disable-shared \

--prefix=/usr/local \

"CC=clang" \

"CFLAGS=$cflags -miphoneos-version-min=12.0 -arch arm64 -isysroot 
$isysroot" \

"CXX=clang" \

"CXXFLAGS=$cxxflags -miphoneos-version-min=12.0 -arch arm64 -isysroot 
$isysroot" \

LDFLAGS="-arch arm64 -miphoneos-version-min=12.0 -stdlib=libc++" \

"LIBS=-lc++ -lc++abi"


make -j8

make install


///////////////////////////////////////////////////////////////////


lipo -info libprotobuf.a

Non-fat file: libprotobuf.a is architecture: arm64


lipo -info Release-iphoneos/libphonenumber.a

Non-fat file: Release-iphoneos/libphonenumber.a is architecture: arm64


Undefined symbols for architecture arm64:

  "google::protobuf::internal::LogMessage::operator<<(char const*)", 
referenced from:

      ____ZN13ContactReaper14gatherContactsEv_block_invoke in xxx_lto.o

      
google::protobuf::internal::ArenaStringPtr::CreateInstance(google::protobuf::Arena*,
 
std::__1::basic_string<char, std::__1::char_traits<char>, 
std::__1::allocator<char> > const*) in xxx_lto.o

  "google::protobuf::internal::LogMessage::~LogMessage()", referenced from:

      ____ZN13ContactReaper14gatherContactsEv_block_invoke in xxx_lto.o

      
google::protobuf::internal::ArenaStringPtr::CreateInstance(google::protobuf::Arena*,
 
std::__1::basic_string<char, std::__1::char_traits<char>, 
std::__1::allocator<char> > const*) in xxx_lto.o

  "google::protobuf::internal::ReadSizeFallback(char const*, unsigned 
int)", referenced from:

      i18n::phonenumbers::PhoneMetadata::_InternalParse(char const*, 
google::protobuf::internal::ParseContext*) in 
libphonenumber.a(phonemetadata.pb.o)

      i18n::phonenumbers::PhoneMetadataCollection::_InternalParse(char 
const*, google::protobuf::internal::ParseContext*) in 
libphonenumber.a(phonemetadata.pb.o)


etc... 41 of them.


been at this for 2 days, and for the life of me can't figure out how to fix 
it.


has anyone else made it through this alive?

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/c4e06027-f56c-465f-bc44-752c5607bbbd%40googlegroups.com.

Reply via email to