Reputation: 199
I saw libpcap here https://github.com/the-tcpdump-group/libpcap?files=1
I have compiler for arm linux.
How can I build libpcap to a file
so I can statically link to this lib in my project?
I didn't find MakeFile for Arm.
Upvotes: 0
Views: 2768
Reputation: 5895
On Ubuntu 16.04 86_64 or later, assuming bison and flex were installed, and gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf.tar.xz was downloaded and extracted into the /opt
directory, a possible procedure for cross-compiling the latest version from scratch would be:
wget https://github.com/the-tcpdump-group/libpcap/archive/libpcap-1.9.1.tar.gz
tar zxf libpcap-1.9.1.tar.gz
cd libpcap-libpcap-1.9.1
CROSS_COMPILE=/opt/arm/9/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf- CC=${CROSS_COMPILE}gcc ./configure --host=arm-none-linux-gnueabihf --prefix=$(pwd)/libpcap-1.9.1-arm-none-linux-gnueabihf
CROSS_COMPILE=/opt/arm/9/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf- CC=${CROSS_COMPILE}gcc make install
The libraries and include files will be installed in libpcap-libpcap-1.9.1/libpcap-1.9.1-arm-none-linux-gnueabihf
:
ls -gG -a libpcap-1.9.1-arm-none-linux-gnueabihf/include libpcap-1.9.1-arm-none-linux-gnueabihf/lib
libpcap-1.9.1-arm-none-linux-gnueabihf/include:
total 24
drwxr-xr-x 3 4096 Feb 6 13:07 .
drwxrwxr-x 6 4096 Feb 6 13:07 ..
drwxr-xr-x 2 4096 Feb 6 13:07 pcap
-rw-r--r-- 1 2294 Feb 6 13:07 pcap-bpf.h
-rw-r--r-- 1 2226 Feb 6 13:07 pcap.h
-rw-r--r-- 1 2024 Feb 6 13:07 pcap-namedb.h
libpcap-1.9.1-arm-none-linux-gnueabihf/lib:
total 2108
drwxr-xr-x 3 4096 Feb 6 13:07 .
drwxrwxr-x 6 4096 Feb 6 13:07 ..
-rw-r--r-- 1 1199090 Feb 6 13:07 libpcap.a
lrwxrwxrwx 1 12 Feb 6 13:07 libpcap.so -> libpcap.so.1
lrwxrwxrwx 1 16 Feb 6 13:07 libpcap.so.1 -> libpcap.so.1.9.1
-rwxr-xr-x 1 942752 Feb 6 13:07 libpcap.so.1.9.1
drwxr-xr-x 2 4096 Feb 6 13:07 pkgconfig
I hope this helps.
Just a remainder: Flex and Bison can be installed using:
sudo apt-get install flex bison
Upvotes: 1