将本机节点模块编译到 Android 时无法链接库.使用 -fPIC 标志时出现 -fPIC 问题重新编译



这个问题主要与node-gyp,GCC和NDK工具链有关,但我会添加完整的上下文,因为它可能是必要的。

上下文

我正在使用 React Native 构建一个应用程序。由于我需要在此应用程序中使用节点原生库,因此我使用此节点模块nodejs-mobile在Android和iOS上运行Node.js进程。

添加作曲家-管理模块时,我在 Android 上遇到了编译问题。

错误

链接composer-admin依赖项所需的grpc_node模块时,编译器失败。错误是:

[LIB 1 PATH OMITTED] requires unsupported dynamic reloc R_ARM_REL32; recompile with -fPIC ... [LIB N PATH OMITTED] requires unsupported dynamic reloc R_ARM_REL32; recompile with -fPIC clang70++: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [grpc_node.target.mk:189: Release/obj.target/grpc_node.node] Error 1 make: Leaving directory '/home/vanclief/Cacao_repos/react-app/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-armeabi-v7a/nodejs-project/node_modules/fabric-client/node_modules/grpc/build'

奇怪的是,-fPIC标志正在按照 common.gypi 中的指定使用:

/home/vanclief/Cacao_repos/react-app/android/build/standalone-toolchains/arm-linux-androideabi/bin/arm-linux-androideabi-clang++ -shared -g -rdynamic -fPIC -Wl,-soname=grpc_node.node -o

这是完整的编译日志

common.gypi 是错误的。它在 ldflags 中-fPIC。它需要在旗帜中。

最新更新