leenjewel / openssl_for_ios_and_android

OpenSSL Library for iOS and Android
920 stars 317 forks source link

链接失败 #48

Closed kotori2 closed 5 years ago

kotori2 commented 5 years ago
Build command failed.
Error while executing process C:\Users\[REMOVED]\AppData\Local\Android\Sdk\cmake\3.10.2.4988404\bin\cmake.exe with arguments {--build [REMOVED]\app\.externalNativeBuild\cmake\debug\arm64-v8a --target security}
[1/3] Building CXX object CMakeFiles/security.dir/util.cpp.o
[2/3] Building CXX object CMakeFiles/security.dir/security.cpp.o
[3/3] Linking CXX shared library [REMOVED]\app\build\intermediates\cmake\debug\obj\arm64-v8a\libsecurity.so
FAILED: [REMOVED]/app/build/intermediates/cmake/debug/obj/arm64-v8a/libsecurity.so 
cmd.exe /C "cd . && C:\Users\[REMOVED]\AppData\Local\Android\sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=aarch64-none-linux-android21 --gcc-toolchain=C:\Users\[REMOVED]\AppData/Local/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=C:\Users\[REMOVED]\AppData/Local/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -Wa,--noexecstack -Wformat -Werror=format-security  -frtti -fexceptions -O0 -fno-limit-debug-info  -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -Wl,-z,noexecstack -shared -Wl,-soname,libsecurity.so -o [REMOVED]\app\build\intermediates\cmake\debug\obj\arm64-v8a\libsecurity.so CMakeFiles/security.dir/security.cpp.o CMakeFiles/security.dir/util.cpp.o  -llog [REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a [REMOVED]/app/src/main/jni/../libs/arm64-v8a/libssl.a -latomic -lm && cd ."
[REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a(c_zlib.o): In function `zlib_stateful_init':
c_zlib.c:(.text+0x7c): undefined reference to `inflateInit_'
c_zlib.c:(.text+0xa8): undefined reference to `deflateInit_'
[REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a(c_zlib.o): In function `zlib_stateful_finish':
c_zlib.c:(.text+0x104): undefined reference to `inflateEnd'
c_zlib.c:(.text+0x10c): undefined reference to `deflateEnd'
[REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a(c_zlib.o): In function `zlib_stateful_compress_block':
c_zlib.c:(.text+0x164): undefined reference to `deflate'
[REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a(c_zlib.o): In function `zlib_stateful_expand_block':
c_zlib.c:(.text+0x1d8): undefined reference to `inflate'
[REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a(c_zlib.o): In function `bio_zlib_write':
c_zlib.c:(.text+0x318): undefined reference to `deflateInit_'
c_zlib.c:(.text+0x3b0): undefined reference to `deflate'
c_zlib.c:(.text+0x3dc): undefined reference to `zError'
[REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a(c_zlib.o): In function `bio_zlib_read':
c_zlib.c:(.text+0x4e8): undefined reference to `inflateInit_'
c_zlib.c:(.text+0x524): undefined reference to `inflate'
c_zlib.c:(.text+0x5ac): undefined reference to `zError'
[REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a(c_zlib.o): In function `bio_zlib_ctrl':
c_zlib.c:(.text+0x78c): undefined reference to `deflate'
c_zlib.c:(.text+0x86c): undefined reference to `zError'
[REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a(c_zlib.o): In function `bio_zlib_free':
c_zlib.c:(.text+0x954): undefined reference to `inflateEnd'
c_zlib.c:(.text+0x978): undefined reference to `deflateEnd'
[REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a(cryptlib.o): In function `OPENSSL_showfatal':
cryptlib.c:(.text+0x2c): undefined reference to `stderr'
cryptlib.c:(.text+0x34): undefined reference to `stderr'
[REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a(eng_openssl.o): In function `openssl_load_privkey':
eng_openssl.c:(.text+0x350): undefined reference to `stderr'
eng_openssl.c:(.text+0x354): undefined reference to `stderr'
[REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a(eng_openssl.o): In function `test_rc4_init_key':
eng_openssl.c:(.text+0x534): undefined reference to `stderr'
[REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a(eng_openssl.o):eng_openssl.c:(.text+0x538): more undefined references to `stderr' follow
[REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a(ui_openssl.o): In function `open_console':
ui_openssl.c:(.text+0x68): undefined reference to `stdin'
ui_openssl.c:(.text+0x6c): undefined reference to `stdin'
ui_openssl.c:(.text+0x9c): undefined reference to `stderr'
ui_openssl.c:(.text+0xa0): undefined reference to `stderr'
[REMOVED]/app/src/main/jni/../libs/arm64-v8a/libcrypto.a(ui_openssl.o): In function `close_console':
ui_openssl.c:(.text+0x374): undefined reference to `stdin'
ui_openssl.c:(.text+0x378): undefined reference to `stdin'
ui_openssl.c:(.text+0x3a0): undefined reference to `stderr'
ui_openssl.c:(.text+0x3a4): undefined reference to `stderr'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
kotori2 commented 5 years ago

貌似是编译时指定的SDK版本太低了。。我调高自己编译一遍试试

kotori2 commented 5 years ago

https://github.com/openssl/openssl/issues/988 调整minSdkVersion>20解决了undefined reference to 'stderr'的问题

kotori2 commented 5 years ago

https://github.com/openssl/openssl/issues/7372 这边issue说的是因为加了-static标签,但是实际使用上来看,编辑CMakeLists.txt,在target_link_libraries中添加z(zlib),即可解决