如何解决交叉编译ARM的protobuf时出错:./libs / libprotoc.so:错误:对'descriptor的未定义引用
交叉编译ARM的protobuf时出错
编译脚本:
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
配置中没有错误,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
环境
Linux x 5.6.15-arch1-1
GNU Make 4.3
NDK (Side by side) 21.1.6352462
protobuf v3.13.0
有趣的是,尽管报告了错误,但诸如.so之类的库文件是在protobuf / src / .libs下获得的。
解决方法
我在 Linux (debian 4.19.0-16-amd64) 上编译 armv7a-linux-androideabi
时也遇到此错误
正如您所说,“没问题”,因为库是在 src/.libs
中创建的,并且它们似乎工作正常(至少 libprotobuf.so
)
我使用旧版本的 ndk-r21 (Pkg.Revision = 21.0.6113669) 没有问题 我最近更新到最新的 ndk-r21e (21.4.7075529),我发现问题是...
PS:aarch64-linux-android
不会发生这种情况
这是一个链接 on Qt forum on the topic。
对于那些有兴趣的人,here is my compile script 构建 x86_64 版本以及 Android 32 和 64 位。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。