TFレポのcontrib/makefile
で提供されているスクリプトを使用してTensorflowを構築しました。私が端末出力から知る限り、生成されたlibtensorflow-core.a
は-fPIC
を有効にしてコンパイルされていたはずです。スタティックライブラリリンクエラー "サポートされていないダイナミックリロケーションが必要"
は今、私はこれがobjdump
$ objdump -r libtensorflow-core.a
libtensorflow-core.a(test_log.pb.o): file format ELF32-arm-little
RELOCATION RECORDS FOR [.rel.text]:
0000075c R_ARM_CALL _ZN6google8protobuf8internal14WireFormatLite24WriteMessageMaybeToArrayEiRKNS0_11MessageLiteEPNS0_2io17CodedOutputStreamE
000009b8 R_ARM_CALL _ZN6google8protobuf8internal14WireFormatLite10WriteInt64EixPNS0_2io17CodedOutputStreamE
000009cc R_ARM_CALL _ZN6google8protobuf8internal14WireFormatLite10WriteInt64EixPNS0_2io17CodedOutputStreamE
00000a1c R_ARM_CALL _ZN6google8protobuf8internal14WireFormatLite16VerifyUtf8StringEPKciNS2_9OperationES4_
00000a34 R_ARM_CALL _ZN6google8protobuf8internal14WireFormatLite11WriteStringEiRKSsPNS0_2io17CodedOutputStreamE
00000a44 R_ARM_REL32 .LC3
...
の出力である
libtensorflow-core.a(config.pb.o): requires unsupported dynamic reloc R_ARM_REL32; recompile with -fPIC
で
add_library(lib_tf STATIC IMPORTED)
set_target_properties(lib_tf PROPERTIES IMPORTED_LOCATION ${TF_BUILD}/libtensorflow-core.a)
add_library(native-lib SHARED ${SRC})
target_link_libraries(native-lib lib_tf)
それは文句を言うとAndroidのNDKプロジェクトの共有ライブラリにそのライブラリをリンクしようとすると、
それは-fPIC
でコンパイルされたようです。私は問題が何であるか分かりません。
UPDATE:
私は、Android NDKアームツールチェーンを経由して、手動でそれをコンパイルし、それが働きました。 Androidスタジオの違いは分かりません。