Build From Source for Android
Table of contents
- Prerequisites
- Configuration
- Build the code
- Do I need a rooted device in order to use PcapPlusPlus in my Android app?
- Using PcapPlusPlus in my app
Prerequisites
In order to build PcapPlusPlus for Android please make sure you have the following prerequisites:
- A Linux machine - building on other platforms is currently not supported
- You should have Android NDK installed
- Pre-compiled
libpcap
library for Android + header files which can be downloaded from thelibpcap-android
GitHub repo (for Android API versions 21-30)
Configuration
Run the configuration script from PcapPlusPlus main directory:
./configure-android.sh
This script accepts the following arguments:
Argument | Is mandatory / default value | Description |
---|---|---|
--ndk-path |
Mandatory | The path of Android NDK, for example: /opt/Android/Sdk/ndk/22.0.7026061 |
--target |
Mandatory | Target architecture which accepts the following values: arm64-v8a , armeabi-v7a , x86 , x86_64 |
--api |
Optional. Default value is 29 |
Android API level. Must be between 21 and 30 |
--libpcap-include-dir |
Mandatory | libpcap header files directory. Can be downloaded from the libpcap-android GitHub repo |
--libpcap-lib-dir |
Mandatory | libpcap pre-compiled libs directory. Can be downloaded from the libpcap-android GitHub repo for all 4 targets and API versions 21-30 |
Here is an example output:
seladb@ubunu2004:~/PcapPlusPlus$ ./configure-android.sh --ndk-path /opt/Android/Sdk/ndk/22.0.7026061 --target arm64-v8a --api 29 --libpcap-include-dir ~/libpcap-android/include --libpcap-lib-dir ~/libpcap-android/arm64-v8a/29
******************************************
PcapPlusPlus Android configuration script
******************************************
PcapPlusPlus configuration is complete. Files created (or modified): mk/platform.mk, mk/PcapPlusPlus.mk
Build the code
After running the config script, you’re can safely build the code:
- Run
make libs
to build PcapPlusPlus libraries only (which is the common use-case for Android) ormake all
to build everything including the unit-tests and examples - After a successful build you can find the libraries, header files, example executables (if built) and helpful makefiles under the
Dist
directory - Please notice that in order to run PcapPlusPlus examples on an Android device you need shell access, and for some of them you also need a rooted device
Do I need a rooted device in order to use PcapPlusPlus in my Android app?
Not at all! Please follow this link
Using PcapPlusPlus in my app
Please follow this link