leenjewel / openssl_for_ios_and_android

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

找不到zlib? #17

Closed cjxqhhh closed 7 years ago

cjxqhhh commented 7 years ago

请问cmakelist里面需要加和zlib有关的项目吗?我这里一直没有办法运行: image 谢谢~

xiaozhi003 commented 7 years ago
find_library( z-lib z )

include_directories( ${OpenSSL_DIR}/include )

# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.

target_link_libraries( # Specifies the target library.
                       keystore

                       # Links the target library to the log library
                       # included in the NDK.
                       ssl
                       crypto
                       ${log-lib}
                       ${z-lib})

把zlib添加进去就好

cjxqhhh commented 7 years ago

image 现在变成这个错误了?求教~

leenjewel commented 7 years ago

OpenSSL 静态库是你自己编译的么?

cjxqhhh commented 7 years ago

不是,是直接用你这里的~

leenjewel commented 7 years ago

你尝试编译我那个 Example 了么?

cjxqhhh commented 7 years ago

嗯嗯,那个android的example是吧? image 我这里只是用aes的话不报错,用到hmac的时候就错了

leenjewel commented 7 years ago

方便贴一下 C++ 的代码吗?我写到 Example 里编译试试

cjxqhhh commented 7 years ago

void hmacSha256(unsigned char output, const char key, const char input, unsigned int &outputLen) { const EVP_MD engine = EVP_sha256(); output = (unsigned char)malloc(EVP_MAX_MD_SIZE); HMAC_CTX ctx = HMAC_CTX_new(); HMAC_Init_ex(ctx, key, strlen(key), engine, NULL); HMAC_Update(ctx, (unsigned char *)input, strlen(input)); HMAC_Final(ctx, output, &outputLen); HMAC_CTX_free(ctx);

}

你试下这个函数能不能跑?别的代码可能不方便贴,非常抱歉啊~

leenjewel commented 7 years ago

参看

https://github.com/openssl/openssl/issues/988

http://stackoverflow.com/questions/37122126/whats-the-exact-significance-of-android-ndk-platform-version-compared-to-api-le

貌似需要使用 NDK 并且 Android-21 以前版本编译的 OpenSSL 才支持,我尝试重新编译看看

cjxqhhh commented 7 years ago

嗯嗯,我也看到这些资料了,这个东西搞了一天,惨,你有时间的话试试哈~辛苦了

leenjewel commented 7 years ago

解决了,用低版本的 API 重新编译一下就好了,你给我你邮箱,我发你我编译好的,低版本编译的问题就是不支持 64 位 ARM 设备的编译,不过这个还好。。。。。。影响不大

cjxqhhh commented 7 years ago

cjxqhhh@gmail.com,谢谢~

TroyRay commented 7 years ago

810196673@qq.com 也发我一个吧,怎么都有错误,快哭了。。。 @leenjewel

leenjewel commented 7 years ago

已经上传到 GitHub 了,直接下载即可