ipsn / go-libtor

Self-contained Tor from Go
BSD 3-Clause "New" or "Revised" License
544 stars 46 forks source link

Android bind is not working #12

Closed lu4p closed 4 years ago

lu4p commented 4 years ago

I used the provided example for android but got this error while building. Any suggestions on how to mitigate this issue?

Command used to build: gomobile bind -v -x .

Error Log

# github.com/ipsn/go-libtor/libtor
../github.com/ipsn/go-libtor/libtor/../openssl/include/../crypto/rand/rand_unix.c:392: error: undefined reference to 'shmget'
../github.com/ipsn/go-libtor/libtor/../openssl/include/../crypto/rand/rand_unix.c:437: error: undefined reference to 'shmat'
../github.com/ipsn/go-libtor/libtor/../openssl/include/../crypto/rand/rand_unix.c:426: error: undefined reference to 'shmget'
../github.com/ipsn/go-libtor/libtor/../openssl/include/../crypto/rand/rand_unix.c:370: error: undefined reference to 'shmdt'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
# github.com/ipsn/go-libtor/libtor
In file included from ../github.com/ipsn/go-libtor/libtor/openssl_crypto_rand_rand_unix.go:11:
../github.com/ipsn/go-libtor/libtor/../openssl/include/../crypto/rand/rand_unix.c:370:5: warning: implicit declaration of function 'shmdt' is invalid in C99 [-Wimplicit-function-declaration]
../github.com/ipsn/go-libtor/libtor/../openssl/include/../crypto/rand/rand_unix.c:392:23: warning: implicit declaration of function 'shmget' is invalid in C99 [-Wimplicit-function-declaration]
../github.com/ipsn/go-libtor/libtor/../openssl/include/../crypto/rand/rand_unix.c:437:24: warning: implicit declaration of function 'shmat' is invalid in C99 [-Wimplicit-function-declaration]
../github.com/ipsn/go-libtor/libtor/../openssl/include/../crypto/rand/rand_unix.c:437:22: warning: incompatible integer to pointer conversion assigning to 'void *' from 'int' [-Wint-conversion]
# github.com/ipsn/go-libtor/libtor
In file included from ../github.com/ipsn/go-libtor/libtor/zlib_gzlib.go:7:
../github.com/ipsn/go-libtor/libtor/../zlib/gzlib.c:252:9: warning: implicit declaration of function 'lseek' is invalid in C99 [-Wimplicit-function-declaration]
../github.com/ipsn/go-libtor/libtor/../zlib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
../github.com/ipsn/go-libtor/libtor/../zlib/gzlib.c:258:24: warning: implicit declaration of function 'lseek' is invalid in C99 [-Wimplicit-function-declaration]
../github.com/ipsn/go-libtor/libtor/../zlib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
../github.com/ipsn/go-libtor/libtor/../zlib/gzlib.c:359:9: warning: implicit declaration of function 'lseek' is invalid in C99 [-Wimplicit-function-declaration]
../github.com/ipsn/go-libtor/libtor/../zlib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
../github.com/ipsn/go-libtor/libtor/../zlib/gzlib.c:400:15: warning: implicit declaration of function 'lseek' is invalid in C99 [-Wimplicit-function-declaration]
../github.com/ipsn/go-libtor/libtor/../zlib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
../github.com/ipsn/go-libtor/libtor/../zlib/gzlib.c:496:14: warning: implicit declaration of function 'lseek' is invalid in C99 [-Wimplicit-function-declaration]
../github.com/ipsn/go-libtor/libtor/../zlib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
# github.com/ipsn/go-libtor/libtor
In file included from ../github.com/ipsn/go-libtor/libtor/zlib_gzread.go:7:
../github.com/ipsn/go-libtor/libtor/../zlib/gzread.c:35:15: warning: implicit declaration of function 'read' is invalid in C99 [-Wimplicit-function-declaration]
../github.com/ipsn/go-libtor/libtor/../zlib/gzread.c:651:11: warning: implicit declaration of function 'close' is invalid in C99 [-Wimplicit-function-declaration]
# github.com/ipsn/go-libtor/libtor
In file included from ../github.com/ipsn/go-libtor/libtor/zlib_gzwrite.go:7:
../github.com/ipsn/go-libtor/libtor/../zlib/gzwrite.c:89:20: warning: implicit declaration of function 'write' is invalid in C99 [-Wimplicit-function-declaration]
../github.com/ipsn/go-libtor/libtor/../zlib/gzwrite.c:110:24: warning: implicit declaration of function 'write' is invalid in C99 [-Wimplicit-function-declaration]
../github.com/ipsn/go-libtor/libtor/../zlib/gzwrite.c:661:9: warning: implicit declaration of function 'close' is invalid in C99 [-Wimplicit-function-declaration]
rm -r -f "$WORK"
gomobile: go build -v -x -buildmode=c-shared -o=/tmp/gomobile-work-178710928/android/src/main/jniLibs/armeabi-v7a/libgojni.so gobind failed: exit status 2
karalabe commented 4 years ago

The zlib warnings have been fixes a while back. Does this issue still happen to you? I didn't try building from macos(clang) so not sure if something's limited by the C compiler there.

lu4p commented 4 years ago

Will check today

lu4p commented 4 years ago

build worked can you share your android example project so i can check?

karalabe commented 4 years ago

I don't think I have an example project stashed away anywhere at the moment. If the build succeeded, I guess everything should work ok. I've build various prototypes on and off, but don't have anything reasonably clean to share.