heiher / hev-socks5-tunnel

A high-performance tun2socks for Linux/Android/FreeBSD/macOS/iOS/WSL2 (IPv4/IPv6/TCP/UDP)
MIT License
636 stars 130 forks source link

can't make so files in android studio #94

Closed itsDantes closed 4 months ago

itsDantes commented 4 months ago

i can't make so files for this lib and use it in my android projects.

i test 2 way . first i cloned your android project - sockstun into my android studio and getting this error

e1 In file included from C:/Users/windows/StudioProjects/sockstun/app/src/main/jni/hev-socks5-tunnel/src/core/src/hev-socks5-client-tcp.c:12: C:/Users/windows/StudioProjects/sockstun/app/src/main/jni/hev-socks5-tunnel/third-part/hev-task-system/include/hev-memory-allocator.h:1:1: error: expected identifier or '(' ../src/mem/api/hev-memory-allocator-api.h ^ your sockstun project it outdated , i upgraded your project gradle and finaly could run your project but getting this error.

also there is another project that use your lib, but this project is also use sockstun ways and using externalNativeBuild for making so files. is there another android project that use this lib ? bc both of that projects using same way and both is not working.

then i tried to build it via windows cmd by this way: e2

my cmd was:

mkdir hev-socks5-tunnel
cd hev-socks5-tunnel
git clone --recursive https://github.com/heiher/hev-socks5-tunnel jni
C:\Users\windows\AppData\Local\Android\Sdk\ndk\25.1.8937393\ndk-build

whats the problem ? how can make .so files for my android project?

heiher commented 4 months ago

https://github.com/heiher/hev-socks5-tunnel/issues/5#issuecomment-765883956

itsDantes commented 4 months ago

@heiher i getting this error because running this command in windows ? so what about sockstun project? it also not working in android studio and getting below error as i said :

In file included from C:/Users/windows/StudioProjects/sockstun/app/src/main/jni/hev-socks5-tunnel/src/core/src/hev-socks5-client-tcp.c:12: C:/Users/windows/StudioProjects/sockstun/app/src/main/jni/hev-socks5-tunnel/third-part/hev-task-system/include/hev-memory-allocator.h:1:1: error: expected identifier or '(' ../src/mem/api/hev-memory-allocator-api.h ^

if both is windows so where should we run android ndk-build ? linux? should i download ndk-build for linux and make project there?

heiher commented 4 months ago

hev-socks5-tunnel (and submodules) contain symlink files, which are not supported on Windows file systems. So sockstun can only be compiled on Unix systems, including WSL. Only the command line SDK is required.

itsDantes commented 4 months ago

@heiher well, i installed linux command line and make command getting error

Untitled

itsDantes commented 4 months ago

the only way that not getting error is below folder structure

in my android src\main i made an jni folder:

sdw

so my folder structure is like jni\hev-socks5-tunnel\jni. by this way when i run make my project in androidStudio like this command - externalNativeBuild everyhing works fine and i getting no error, but there is no .so files in my android project. you can see output of made projects

make

is this folder structure is wrong ? why i cant made this lib in my project?

also after getting this error ;

In file included from C:/Users/windows/Desktop/project/app/src/main/jni/hev-socks5-tunnel/src/core/src/hev-socks5-client-tcp.c:12:
C:/Users/windows/Desktop/project/app/src/main/jni/hev-socks5-tunnel/third-part/hev-task-system/include/hev-memory-allocator.h:1:1: error: expected identifier or '('
../src/mem/api/hev-memory-allocator-api.h
^
In file included from C:/Users/windows/Desktop/project/app/src/main/jni/hev-socks5-tunnel/src/core/src/hev-socks5-client-tcp.c:12:
C:/Users/windows/Desktop/project/app/src/main/jni/hev-socks5-tunnel/third-part/hev-task-system/include/hev-memory-allocator.h:1:1: error: expected identifier or '('
../src/mem/api/hev-memory-allocator-api.h
^

i opened android_gradle_build file to see the logs and outputs, it mention that an .so file made this following path

Untitled

C:\Users\windows\Desktop\project\app\build\intermediates\cxx\Debug\6n486i33\obj\local\arm64-v8a\libhev-socks5-tunnel.so

but when i follow this path, there is no so file. dw

====================

but when i use src\main\jni\hev-socks5-tunnel folder structure i getting error as below Untitled

In file included from C:/Users/windows/Desktop/project/app/src/main/jni/hev-socks5-tunnel/src/core/src/hev-socks5-client-tcp.c:12:
C:/Users/windows/Desktop/project/app/src/main/jni/hev-socks5-tunnel/third-part/hev-task-system/include/hev-memory-allocator.h:1:1: error: expected identifier or '('
../src/mem/api/hev-memory-allocator-api.h
^
In file included from C:/Users/windows/Desktop/project/app/src/main/jni/hev-socks5-tunnel/src/core/src/hev-socks5-client-tcp.c:12:
C:/Users/windows/Desktop/project/app/src/main/jni/hev-socks5-tunnel/third-part/hev-task-system/include/hev-memory-allocator.h:1:1: error: expected identifier or '('
../src/mem/api/hev-memory-allocator-api.h
^

doese externalNativeBuild command should not build projects automatically and ignore windows symlink files ?

i have linux and windows terminals like below: Untitled but no Unix or Android is working by command line (manually) and always getting error.

i even followed sockstun project and import it via my android studio and still getting the error: expected identifier or error all time. is there something missing in my computer or android studio?

itsDantes commented 4 months ago

finally i replaced all of c header files as below format and errors fixed.

ff