我试图在jni文件夹中从netguard本机库创建一个.so文件,但是我收到此错误" collect2 ld返回1退出状态"在我执行" ndk-build"之后。我希望有人帮助创建一个.so文件。
项目路径:https://github.com/M66B/NetGuard
我的Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
APP_PROJECT_PATH := /home/mishael/AndroidStudioProjects/NetGuard/app/src/main/jni/netguard/
APP_PLATFORM=android-14
APP_ABI := armeabi armeabi-v7a x86 mips
LOCAL_MODULE := netguard
LOCAL_SRC_FILES := netguard.c
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
错误消息
ndk-build NDK_APPLICATION_MK=Application.mk [armeabi] Compile thumb :
netguard <= netguard.c In file included from ./netguard.c:20:0:
./netguard.h:203:1: warning: useless storage class specifier in empty
declaration [enabled by default] } __packed; ^ ./netguard.h:210:1:
warning: useless storage class specifier in empty declaration [enabled by
default] } __packed; ^ ./netguard.h:262:1: warning: useless storage class
specifier in empty declaration [enabled by default] } __packed; ^
./netguard.h:284:1: warning: useless storage class specifier in empty
declaration [enabled by default] } __packed; ^ ./netguard.h:289:1:
warning: useless storage class specifier in empty declaration [enabled by
default] } __packed; ^ ./netguard.c: In function
'Java_eu_faircode_netguard_SinkholeService_jni_get_stats':
./netguard.c:216:5: warning: passing argument 4 of
'(*env)->ReleaseIntArrayElements' makes integer from pointer without a
cast [enabled by default] (*env)->ReleaseIntArrayElements(env, jarray,
jcount, NULL); ^ ./netguard.c:216:5: note: expected 'jint' but argument
is of type 'void *' [armeabi] SharedLibrary : libnetguard.so
./netguard.c:84: error: undefined reference to 'log_android'
./netguard.c:88: error: undefined reference to 'log_android'
./netguard.c:104: error: undefined reference to 'init_icmp'
./netguard.c:105: error: undefined reference to 'init_udp'
./netguard.c:106: error: undefined reference to 'init_tcp'
./netguard.c:111: error: undefined reference to 'log_android'
./netguard.c:112: error: undefined reference to 'pcap_file'
./netguard.c:120: error: undefined reference to 'log_android'
./netguard.c:151: error: undefined reference to 'max_tun_msg'
./netguard.c:151: error: undefined reference to 'handle_events'
./netguard.c:172: error: undefined reference to 'clear_icmp'
./netguard.c:173: error: undefined reference to 'clear_udp'
./netguard.c:174: error: undefined reference to 'clear_tcp'
./netguard.c:194: error: undefined reference to 'get_icmp_sessions'
./netguard.c:195: error: undefined reference to 'get_udp_sessions'
./netguard.c:196: error: undefined reference to 'get_tcp_sessions'
./netguard.c:265: error: undefined reference to 'write_pcap_hdr'
./netguard.c:276: error: undefined reference to 'pcap_record_size'
./netguard.c:276: error: undefined reference to 'pcap_file_size'
./netguard.c:276: error: undefined reference to 'pcap_file'
./netguard.c:283: error: undefined reference to 'clear_icmp'
./netguard.c:284: error: undefined reference to 'clear_udp'
./netguard.c:285: error: undefined reference to 'clear_tcp' collect2:
error: ld returned 1 exit status make: *** [/home/mishael
/AndroidStudioProjects/NetGuard/app/src/main/obj/local/armeabi
/libnetguard.so] Error 1
答案 0 :(得分:0)
构建NetGuard本机代码已集成在NetGuard Android Studio项目中,因此我猜您正在使其变得更加困难。