alexxy / netdiscover

netdiscover
GNU General Public License v3.0
380 stars 89 forks source link

Failed to make on MacOS 10.14.4 #15

Open rpranshu opened 5 years ago

rpranshu commented 5 years ago

On MacOS Mojave, the build fails giving the following output

$ cmake .

-- The C compiler identification is AppleClang 10.0.1.10010046
-- The CXX compiler identification is AppleClang 10.0.1.10010046
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE
-- Pcap include dirs set to /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include
-- Pcap library set to /usr/lib/libpcap.dylib
-- Looking for pcap_breakloop
-- Looking for pcap_breakloop - found
-- Looking for pcap_datalink_name_to_val
-- Looking for pcap_datalink_name_to_val - found
-- Looking for pcap_datalink_val_to_name
-- Looking for pcap_datalink_val_to_name - found
-- Looking for pcap_findalldevs
-- Looking for pcap_findalldevs - found
-- Looking for pcap_freecode
-- Looking for pcap_freecode - found
-- Looking for pcap_get_selectable_fd
-- Looking for pcap_get_selectable_fd - found
-- Looking for pcap_lib_version
-- Looking for pcap_lib_version - found
-- Looking for pcap_list_datalinks
-- Looking for pcap_list_datalinks - found
-- Looking for pcap_open_dead
-- Looking for pcap_open_dead - found
-- Looking for pcap_set_datalink
-- Looking for pcap_set_datalink - found
-- Found LibNet: /usr/local/lib/libnet.dylib
-- Configuring done
-- Generating done
-- Build files have been written to: netdiscover

$ make

Scanning dependencies of target netdiscover
[ 11%] Building C object src/CMakeFiles/netdiscover.dir/main.c.o
[ 22%] Building C object src/CMakeFiles/netdiscover.dir/ifaces.c.o
netdiscover/src/ifaces.c:207:20: error: use of undeclared identifier
      'SIOCGIFHWADDR'
      if (ioctl(fd,SIOCGIFHWADDR,&ifr)==-1) {
                   ^
netdiscover/src/ifaces.c:215:15: error: no member named 'ifr_hwaddr' in
      'struct ifreq'
      if (ifr.ifr_hwaddr.sa_family!=ARPHRD_ETHER) {
          ~~~ ^
netdiscover/src/ifaces.c:220:46: error: no member named 'ifr_hwaddr' in
      'struct ifreq'
      unsigned char* mac=(unsigned char*)ifr.ifr_hwaddr.sa_data;
                                         ~~~ ^
3 errors generated.
make[2]: *** [src/CMakeFiles/netdiscover.dir/ifaces.c.o] Error 1
make[1]: *** [src/CMakeFiles/netdiscover.dir/all] Error 2
make: *** [all] Error 2
darkcyber commented 5 years ago

on Mac OS Mojave 10.14.2 I face the same issue.

[ 11%] Building C object src/CMakeFiles/netdiscover.dir/ifaces.c.o
/Users//Tools/netdiscover/src/ifaces.c:207:20: error: use of undeclared identifier 'SIOCGIFHWADDR'
      if (ioctl(fd,SIOCGIFHWADDR,&ifr)==-1) {
                   ^
/Users//Tools/netdiscover/src/ifaces.c:215:15: error: no member named 'ifr_hwaddr' in 'struct ifreq'
      if (ifr.ifr_hwaddr.sa_family!=ARPHRD_ETHER) {
          ~~~ ^
/Users//Tools/netdiscover/src/ifaces.c:220:46: error: no member named 'ifr_hwaddr' in 'struct ifreq'
      unsigned char* mac=(unsigned char*)ifr.ifr_hwaddr.sa_data;
                                         ~~~ ^
3 errors generated.
make[2]: *** [src/CMakeFiles/netdiscover.dir/ifaces.c.o] Error 1
make[1]: *** [src/CMakeFiles/netdiscover.dir/all] Error 2
make: *** [all] Error 2
rpranshu commented 5 years ago

Googled a bit regarding this issue. Some libraries and headers are native to linux only. So we'll have to wait for the devs to make it mac compatible