AndroidStudio 3.1 编译libpcap

本文介绍了在Android Studio 3.1版本中,如何利用CMake编译libpcap库。由于网上教程多数针对旧版本Android Studio,作者在Linux环境下编译libpcap并解决了一系列编译错误。步骤包括将编译后的代码放入cpp目录,处理bpf目录下的net链接问题,并提供了CMakeLists.txt的修改方法。完整源码可在指定链接下载。
摘要由CSDN通过智能技术生成

使用百度搜索的很多文章都不能成功编译使用libpcap库。网上写的好像是AndroidStudio2.x的。AndroidStudio官网提供的NDK源码示例好像是使用eclipse的。。。没有学过android/java。。。只是业余研究,想自己写个抓包程序。

studio3.1版本建立的工程勾选使用C++,默认使用的是CMAKE编译。构建工程时自动编译,不需要进入terminal编译。


1、在linux系统下执行./configure && make 编译通过,将代码拷贝到cpp目录下。

    还改了很多编译的错误。过程就不详述了,直接提供源码。

    注意:bpf目录下的net好像是一个链接目录,在windows下不能创建,粘贴复制net目录到bpf下。

2、CMAKE文件中增加要编译的文件

# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html

# Sets the minimum version of CMake required to build the native library.

cmake_minimum_required(VERSION 3.4.1)

# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatical
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值