Make error when cross compiling protobuf for ARM
compiled script:
1 #!/bin/sh
2
3 export PREFIX=$HOME/soft/protobuf_arm/
4 CLANG_TOOLCHAIN=$HOME/soft/arm-29-toolchain-clang
5 export PATH=$CLANG_TOOLCHAIN/bin:$PATH
6 export SYSROOT=$CLANG_TOOLCHAIN/sysroot
7 export CC="armv7a-linux-androideabi29-clang --sysroot $SYSROOT"
8 export CXX="armv7a-linux-androideabi29-clang++ --sysroot $SYSROOT"
9
10 cd $HOME/github/c++/protobuf
11 make clean
12 ./autogen.sh
13 ./configure --prefix=$PREFIX \
14 --host=armv7a-linux-androideabi29 \
15 --with-sysroot="${SYSROOT}" \
16 --enable-shared \
17 --enable-cross-compile \
18 --with-protoc=$HOME/soft/protobuf_linux/protoc \
19 CFLAGS="-march=armv7-a -D__ANDROID_API__=29" \
20 CXXFLAGS="-frtti -fexceptions -march=armv7-a -D__ANDROID_API__=29" \
21 LIBS="-llog -lz -lc++_static"
22 make -j 12
23 make install
There is no error in configure, error in make:
In file included from google/protobuf/compiler/csharp/csharp_source_generator_base.cc:39:
./google/protobuf/compiler/csharp/csharp_source_generator_base.h:62:25: warning: private field 'descriptor_' is not used [-Wunused-private-field]
const FileDescriptor* descriptor_;
^
1 warning generated.
CXXLD libprotoc.la
clang90++: warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument]
clang90++: warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument]
CXXLD protoc
./.libs/libprotoc.so: error: undefined reference to 'descriptor_table_google_2fprotobuf_2fdescriptor_2eproto'
./.libs/libprotoc.so: error: undefined reference to 'scc_info_FileDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto'
clang90++: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [Makefile:3883: protoc] Error 1
make[2]: Leaving directory '/home/sen/github/c++/protobuf/src'
make[1]: *** [Makefile:1866: all-recursive] Error 1
make[1]: Leaving directory '/home/sen/github/c++/protobuf'
make: *** [Makefile:1773: all] Error 2
Environment
Linux x 5.6.15-arch1-1
GNU Make 4.3
NDK (Side by side) 21.1.6352462
protobuf v3.13.0
What is interesting is that although an error was reported, library files such as .so were obtained under protobuf/src/.libs.