1
我使用TF回購的contrib/makefile
中提供的腳本構建了Tensorflow。據我從終端輸出可以看出,生成的libtensorflow-core.a
應該已經被編譯,啓用-fPIC
。靜態庫鏈接錯誤「需要不受支持的動態reloc」
現在,當我試圖在庫
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項目的共享庫
libtensorflow-core.a(config.pb.o): requires unsupported dynamic reloc R_ARM_REL32; recompile with -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
...
輸出
所以它似乎編譯了-fPIC
。我不確定問題是什麼。
UPDATE:
我通過Android NDK手臂工具鏈手動編譯它和它的工作。我不知道Android Studio的不同之處。