Gcc 静态库链接错误“;需要不受支持的动态重新登录“;
我使用TF repo的Gcc 静态库链接错误“;需要不受支持的动态重新登录“;,gcc,cmake,tensorflow,Gcc,Cmake,Tensorflow,我使用TF repo的contrib/makefile中提供的脚本构建了Tensorflow。据我从终端输出可以看出,生成的libtensorflow core.a应该在启用-fPIC的情况下编译 现在,当我尝试将该库链接到Android NDK项目的共享库时 add_library(lib_tf STATIC IMPORTED ) set_target_properties(lib_tf PROPERTIES IMPORTED_LOCATION ${TF_BUILD}/libtensorflo
contrib/makefile
中提供的脚本构建了Tensorflow。据我从终端输出可以看出,生成的libtensorflow core.a
应该在启用-fPIC
的情况下编译
现在,当我尝试将该库链接到Android NDK项目的共享库时
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)
它抱怨说
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
编译的。我不确定是什么问题
更新:
我通过安卓NDK arm工具链手动编译了它,它成功了。我不知道Android工作室有什么不同。 < P>我的C++工具链在我尝试时给了我同样的错误。 将对象链接到android的共享库。错误消失了 当我修复了问题源文件中外部变量的名称空间解析时
namespace {
namespace android {
extern int* sys_id ;
}
}
void home::fileList::report () {
// do stuff
initialize (android::sys_id) ;
// do stuff
}
上面引发“需要不受支持的动态重新登录”错误,下面成功
namespace m1 {
namespace android {
extern int* sys_id ;
}
}
void home::fileList::report () {
// do stuff
initialize (m1::android::sys_id) ;
// do stuff
}