ThomasHabets / arping

ARP Ping
http://www.habets.pp.se/synscan/programs.php
GNU General Public License v2.0
398 stars 62 forks source link

Cross compiling Arping causes multiple definitions error #33

Closed JesusOsuna closed 5 years ago

JesusOsuna commented 5 years ago

Hello,

I am in the task of cross compiling Arping for host arm-none-linux-gnueabi, when trying to do that libnet and libpcap were required as dependencies so I did the follow:

I download libpcap-1.9.0 and configure as follow:

./configure --build=x86_64-pc-linux-gnu --host=arm-none-linux-gnueabi --prefix=/home/uid32119/arping/libpcap-1.9.0/outp --disable-shared --enable-static

then make.

Now, when trying to cross compile Arping again, I am receiving multiple declarations errors as:

arm-none-linux-gnueabi-gcc -DHAVE_CONFIG_H -I. -I.. -I/home/uid32119/arping/libnet-master/libnet/include -I/home/uid32119/arping/libpcap-1.9.0/pcap -D_DEFAULT_SOURCE=1 -g -O2 -MT arping.o -MD -MP -MF .deps/arping.Tpo -c -o arping.o arping.c
In file included from arping.c:111:0:
/home/uid32119/arping/libpcap-1.9.0/pcap/pcap.h:523:18: error: conflicting types for 'bpf_filter'
PCAP_API u_int bpf_filter(const struct bpf_insn *, const u_char *, u_int, u_int);
^
In file included from /home/uid32119/arping/libpcap-1.9.0/pcap/pcap.h:88:0,
from arping.c:111:
/home/uid32119/arping/libnet-master/libnet/include/bpf.h:260:14: note: previous declaration of 'bpf_filter' was here
extern u_int bpf_filter(struct bpf_insn *, u_char *, u_int, u_int);
^
Makefile:613: recipe for target 'arping.o' failed

So I decided to comment /home/uid32119/arping/libpcap-1.9.0/pcap/pcap.h:523 as:

#if !defined(NetBSD) && !defined(QNX)
// PCAP_API u_int bpf_filter(const struct bpf_insn *, const u_char *, u_int, u_int);
#endif

But again, multiple declaration errors arrives:

/home/uid32119/arping/libpcap-1.9.0/.libs/libpcap.a(pcap.o): In function pcap_lookupdev': /home/uid32119/arping/libpcap-1.9.0/./pcap.c:1258: multiple definition of pcap_lookupdev'
mock_libpcap.o:/home/uid32119/arping/arping-arping-2.x/src/mock_libpcap.c:67: first defined here
/home/uid32119/arping/libpcap-1.9.0/.libs/libpcap.a(pcap.o): In function pcap_dispatch': /home/uid32119/arping/libpcap-1.9.0/./pcap.c:2564: multiple definition of pcap_dispatch'
mock_libpcap.o:/home/uid32119/arping/arping-arping-2.x/src/mock_libpcap.c:21: first defined here
/
.
.
.

This is how I configured for Arping:

./configure --build=x86_64-pc-linux-gnu --host=arm-none-linux-gnueabi --prefix=/home/uid32119/arping/arping-arping-2.x/ LDFLAGS="-L/home/uid32119/arping/libnet-master/libnet/src/.libs -L/home/uid32119/arping/libpcap-1.9.0/.libs" CPPFLAGS="-I/home/uid32119/arping/libnet-master/libnet/include -I/home/uid32119/arping/libpcap-1.9.0"

/home/uid32119/arping/libpcap-1.9.0/.libs is just a folder I create to have libpcap.a by itself.

I feel like I am doing something wrong in configure step, maybe you are able to tell me if I am using wrong configure?

Best Regards!

PD: config.log from arping added config.log

ThomasHabets commented 5 years ago

I think you should make install libnet and libpcap, and point includes and libs on the outputs.

But for the error you get running make on arping itself, it looks like it's on the unit tests only. Try just running cd src; make arping, and see if the binary builds fine.

JesusOsuna commented 5 years ago

Hello Thomas,

Just make arping in src works well, as the error was on the unit test. Thank you for your help!

ThomasHabets commented 5 years ago

Happy to help.