leenjewel / openssl_for_ios_and_android

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

error: undefined reference to 'stderr' #20

Open oguzhankosar opened 7 years ago

oguzhankosar commented 7 years ago

While compiling openssl, I'm getting some error as below openssl_error.zip

How can I fix this?

leenjewel commented 7 years ago

Which version of NDK do you use ?

oguzhankosar commented 7 years ago

As you suggested, I use android-ndk-r14b.

leenjewel commented 7 years ago

Which API version do you use?

oguzhankosar commented 7 years ago

I'm using android-16 for openssl and android-21 for curl. I didn't try to compile curl because openssl isn't compiled yet.

peroksid90 commented 6 years ago

You can open tools/_shared.sh and add --deprecated-headers to make_standalone_toolchain.py on line 75.

So it will look like here:

[ -d ${TOOLCHAIN_ROOT} ] || python $NDK/build/tools/make_standalone_toolchain.py \ --api ${ANDROID_API} \ --stl libc++ \ --install-dir=${TOOLCHAIN_ROOT} \ --deprecated-headers \ $NDK_FLAGS

After this you will be able to compile the project using ndk-r15c

az2012 commented 3 years ago

I' SOLVED this infamous compilation problem, open from 4 years.

This library and all this job is excellent, that is wrong is only the second example! ("_https://github.com/leenjewel/openssl_for_ios_and_android/tree/master/example/android/demo2_")

When we compile the static library libcrypto.a libssl.a and libcurl.a, we use different include directory for different architecture "armeabi-v7a" "arm64-v8a" etc.

After we have compilered this basic libraries, we must copy the .a static objects under the corresponding directory and analog we do for include directory. But the first example is correct, infact, it exists a directory per every cpu architecture, "_example/test_cpphttplib_for_app_onandroid/app/src/main/cpp/http/openssl/armeabi-v7a/include/" and _"example/test_cpphttplib_for_app_onandroid/app/src/main/cpp/http/openssl/arm64-v8a/include/", so I can do it , but in the second example, we don't have distinguished subdirectory for every architecure, we found only one directory: _"example/test_curl_with_ssl_and_http2android/app/src/main/cpp/test/include/",
and under this dir, it exists only one directory for every included library, openssl , curl ecc.

NOW what happens if I compile the examples, using "abiFilters 'armeabi-v7a', 'arm64-v8a'" for both archs in build.gradle ?

Very simple, the first example WORKS, the second DON'T WORKS, (the one that use libcurl.a), it catch the infamous error "undefined reference to stderr" This mean,at last, we have copied under the include directory of 2 example the files coming from the include dir of the library of second architecture and lost the files coming from the first arch. So, for the second example, when I write the abifiltes rule, I just can select only one arch every time, and copy the corrisponding libs and include dir from original library, but I cannot have one only abifilters rule to compile for both arctectures at the same time!
Perhaps, or you correct the second example or you correct the README! it's not right?