Closed AaronChen0 closed 3 months ago
Hi thanks but this does not seem to work properly:
C/C++: ld.lld: error: undefined symbol: arc4random_addrandom
C/C++: >>> referenced by evutil_rand.c:198 (src/main/jni/libevent/evutil_rand.c:198)
C/C++: >>> evutil_rand.o:(evutil_secure_rng_add_bytes) in archive /home/circleci/code/core/build/intermediates/cxx/Debug/4474u345/obj/local/arm64-v8a/libevent.a
C/C++: clang: error: linker command failed with exit code 1 (use -v to see invocation)
C/C++: make: *** [/home/circleci/android-sdk/ndk/27.0.12077973/build/core/build-binary.mk:674: /home/circleci/code/core/build/intermediates/cxx/Debug/4474u345/obj/local/arm64-v8a/libredsocks.so] Error 1```
It works in a release build.
Actually, the function evutil_secure_rng_add_bytes
is not used in redsocks
.
In a debug build, if no changes in libevent
submodules, it's hard to fix this undefined symbol
error.
The arc4random_addrandom
is defined in arc4random.c
which contains another undefined symbol: ARC4_LOCK_
.
And ARC4_LOCK_
is defined in evutil_rand.c
, but it depends on a EVENT__HAVE_ARC4RANDOM
macro being undefined.
A solution is removing the function evutil_secure_rng_add_bytes
in libevent
since we don't use it in redsocks
.
Or is there a clang flag to turn this error off?
What a day!
v2ray-plugin
and v2ray-plugin-android
also get updates. :)
Ideally debug should be built too. :)
If there is not a clang flag to turn this error off, I can make a pull request to shadowsocks/libevent
repo to remove the function evutil_secure_rng_add_bytes
since this function is not used in redsocks
and by other functions in libevent
. What do you think?
Hmm libevent hasn't been updated in a while. Maybe pulling upstream is needed.
Check: https://github.com/shadowsocks/libevent/tree/shadowsocks-android
Made a pull request at https://github.com/shadowsocks/libevent/pull/3
Does that fix this?
Yes. The arc4random_addrandom
function is now wrapped around a macro for a change from libevent upstream.
I tested on a test branch. The build finished successfully, and the debug build apk worked in my phone.
Check https://github.com/AaronChen0/shadowsocks-android/tree/update_libevent
After that libevent pull request is merged, I will add a commit to this pull request to update submodule and Android.mk.
Ready to merge.
https://github.com/android/ndk/wiki/Changelog-r26#changes
Since NDK r26, Clang now treats -Wimplicit-function-declaration as an error rather than a warning in C11 and newer.
In the submodules, function
pipe2
inredsocks.c
fromredsocks
and functionarc4random_addrandom
inevutil_rand.c
fromlibevent
are implicitly declared.