-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Link error for android arm64-v8a #17282
Copy link
Copy link
Closed
Milestone
Description
Error occurred while linking dnn module for android arm64-v8a,
3rdparty/lib/arm64-v8a/liblibprotobuf.a(common.cc.o): In function `google::protobuf::internal::DefaultLogHandler(google::protobuf::LogLevel, char const*, int, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)':
3rdparty/protobuf/src/google/protobuf/stubs/common.cc:142: undefined reference to `__android_log_write'
3rdparty/protobuf/src/google/protobuf/stubs/common.cc:150: undefined reference to `__android_log_write'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
After investigation, I found that PR #16400 added --as-needed linker option. Since the default linker is bfd for arm64-v8a as per android/ndk#556, and https://stackoverflow.com/questions/51333069/how-do-the-library-selection-rules-differ-between-gold-and-the-standard-bfd-li states that
For shared libraries under the effect of an --as-needed option,
...
BFD ld marks it "needed" only if the reference precedes the shared library.
There are three solutions I found,
- Explictly link protobuf to log.
- Use gold or lld instead of bfd.
- Link to
OPENCV_LINKER_LIBSlastly in_ocv_create_module.
Reactions are currently unavailable