leenjewel / openssl_for_ios_and_android

OpenSSL Library for iOS and Android
921 stars 318 forks source link

openssl可以用 但是curl用不了 安卓下 #21

Closed stonexing closed 6 years ago

stonexing commented 6 years ago

安卓下刚开始提示"curl_rule_01 declared as an array with a negative size" 修改头文件后 又提示下边这个 怎么解决 Build command failed. Error while executing process /Users/xingyan/Library/Android/sdk/cmake/3.6.4111459/bin/cmake with arguments {--build /Users/xingyan/Desktop/android-ndk-master/jniopenssldemo/app/.externalNativeBuild/cmake/debug/arm64-v8a --target native-lib} [1/3] Building CXX object CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o [2/3] Building CXX object CMakeFiles/native-lib.dir/src/main/cpp/vpnservice.cpp.o /Users/xingyan/Desktop/android-ndk-master/jniopenssldemo/app/src/main/cpp/vpnservice.cpp:30:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ 1 warning generated. [3/3] Linking CXX shared library ../../../../build/intermediates/cmake/debug/obj/arm64-v8a/libnative-lib.so FAILED: : && /Users/xingyan/Library/Android/android-ndk-r14b/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=aarch64-none-linux-android --gcc-toolchain=/Users/xingyan/Library/Android/android-ndk-r14b/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64 --sysroot=/Users/xingyan/Library/Android/android-ndk-r14b/platforms/android-21/arch-arm64 -fPIC -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -O0 -fno-limit-debug-info -O0 -fno-limit-debug-info -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libnative-lib.so -o ../../../../build/intermediates/cmake/debug/obj/arm64-v8a/libnative-lib.so CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o CMakeFiles/native-lib.dir/src/main/cpp/vpnservice.cpp.o libMyAES.a libbase64.a ../../../../src/main/cpp/libs/arm64-v8a/lib/libcurl.a ../../../../src/main/cpp/libs/arm64-v8a/lib/libssl.a ../../../../src/main/cpp/libs/arm64-v8a/lib/libcrypto.a -llog -lm "/Users/xingyan/Library/Android/android-ndk-r14b/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/libgnustl_static.a" && : ../../../../src/main/cpp/libs/arm64-v8a/lib/libcurl.a(libcurl_la-version.o): In functionCurl_version_init': version.c:(.text.Curl_version_init+0x28): undefined reference to zlibVersion' version.c:(.text.Curl_version_init+0x70): undefined reference tozlibVersion' ../../../../src/main/cpp/libs/arm64-v8a/lib/libcurl.a(libcurl_la-version.o): In function curl_version': version.c:(.text.curl_version+0x44): undefined reference tozlibVersion' ../../../../src/main/cpp/libs/arm64-v8a/lib/libcurl.a(libcurl_la-version.o): In function curl_version_info': version.c:(.text.curl_version_info+0x20): undefined reference tozlibVersion' ../../../../src/main/cpp/libs/arm64-v8a/lib/libcurl.a(libcurl_la-content_encoding.o): In function inflate_stream': content_encoding.c:(.text.inflate_stream+0x6c): undefined reference toinflate' content_encoding.c:(.text.inflate_stream+0x8c): undefined reference to inflateEnd' content_encoding.c:(.text.inflate_stream+0xa0): undefined reference toinflateInit2_' content_encoding.c:(.text.inflate_stream+0xc4): undefined reference to inflate' content_encoding.c:(.text.inflate_stream+0x13c): undefined reference toinflateEnd' content_encoding.c:(.text.inflate_stream+0x198): undefined reference to inflateEnd' content_encoding.c:(.text.inflate_stream+0x1ac): undefined reference toinflateEnd' content_encoding.c:(.text.inflate_stream+0x1ec): undefined reference to inflateEnd' content_encoding.c:(.text.inflate_stream+0x1fc): undefined reference toinflateEnd' ../../../../src/main/cpp/libs/arm64-v8a/lib/libcurl.a(libcurl_la-content_encoding.o): In function Curl_unencode_deflate_write': content_encoding.c:(.text.Curl_unencode_deflate_write+0x68): undefined reference toinflateInit_' ../../../../src/main/cpp/libs/arm64-v8a/lib/libcurl.a(libcurl_la-content_encoding.o): In function Curl_unencode_gzip_write': content_encoding.c:(.text.Curl_unencode_gzip_write+0x11c): undefined reference tozlibVersion' content_encoding.c:(.text.Curl_unencode_gzipwrite+0x144): undefined reference to `inflateInit2' content_encoding.c:(.text.Curl_unencode_gzipwrite+0x188): undefined reference to `inflateInit2' content_encoding.c:(.text.Curl_unencode_gzip_write+0x200): undefined reference to inflateEnd' content_encoding.c:(.text.Curl_unencode_gzip_write+0x23c): undefined reference toinflateEnd' ../../../../src/main/cpp/libs/arm64-v8a/lib/libcurl.a(libcurl_la-content_encoding.o): In function Curl_unencode_cleanup': content_encoding.c:(.text.Curl_unencode_cleanup+0x1c): undefined reference toinflateEnd' clang++: error: linker command failed with exit code 1 (use -v to see invocation) ninja: build stopped: subcommand failed. `

leenjewel commented 6 years ago

看样子是没有正确的引入 zlib 库吧?

70kg commented 6 years ago

@stonexing 有解决吗

stonexing commented 6 years ago

解决了就是leenjewel说的问题 没有正确引入zlib 我用的Android studio 解决办法是在build,gradlw(Module:app)中 externalNativeBuild { cmake { cppFlags "" } } 添加-lz 为 externalNativeBuild { cmake { cppFlags "-lz" } }