0

I'm developping an app which needs to use a Java library (jpcap: http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/download.html). The problem is that library uses JNI to call methods written in C code.

In order to call correctly the Java methods I have to compile the C code of the library using the Android NDK. To compile the C code I have to write an Android.mk file to use it with the ndk-build script which provides the NDK.

I've never written before an Android.mk and I don't know how to write the file to fit my needs which are the next:

Compile the following source files:

JpcapCaptor.c JpcapSender.c JpcapWriter.c packet_arp.c packet_datalink.c packet_icmp.c packet_ip.c packet_ipv6.c packet_tcp.c packet_udp.c

Include the following libraries:

jni.h pcap.h

Link using the -lpcap option.

If any of you guys could tell me which lines do I have to write in the Android.mk file or tell me where to find a manual which explains this I would be very thankfull.

Jimix
  • 1,539
  • 3
  • 15
  • 20

1 Answers1

0

Try using this :

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_SRC_FILES := $$Add source files$$

LOCAL_LDLIBS := -lpcap

LOCAL_MODULE := libtest

LOCAL_C_INCLUDES := $$Path of the header files used$$

include $(BUILD_SHARED_LIBRARY)
Karan
  • 12,724
  • 6
  • 40
  • 33
  • I'm getting errors when compiling: "dereferencing pointer to incomplete type". – Jimix Mar 18 '11 at 19:34
  • Please check this http://stackoverflow.com/questions/2943828/how-to-compile-a-static-library-using-the-android-ndk for more details. – Karan Mar 19 '11 at 03:34