Android NDK: Link using a pre-compiled static library

后端 未结 2 1852
陌清茗
陌清茗 2020-11-29 04:25

I\'m trying to port Jnetpcap to Android in order to use it for parsing .pcap files. Jnetpcap is a java wrapper for libpcap which uses JNI. I have compiled libpcap as a stati

2条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-29 04:49

    You have to build pcap as static module. Something like this

    include $(CLEAR_VARS)
    LOCAL_MODULE := pcap
    LOCAL_CFLAGS := declare_flags
    LOCAL_C_INCLUDES := declare_include
    LOCAL_SRC_FILES := src_files
    include $(BUILD_STATIC_LIBRARY)
    

    This build pcap as local module which you could link with LOCAL_STATIC_LIBRARIES

    just add

    LOCAL_STATIC_LIBRARIES := pcap
    

    before calling

    include $(BUILD_SHARED_LIBRARY)
    

提交回复
热议问题