Skip to content

7031a29 fails to build on OS X 10.11.6 #1

@aaaaalbert

Description

@aaaaalbert

7031a29 kind of expectedly causes a few build errors on OS X, particularly multiple errors like these:

./linux/platform.h:11:2: error: "platform is not Linux"
./linux/platform.h:15:10: fatal error: 'endian.h' file not found

Assuming that the #errors about the platform not being Linux are only informative (which is likely a bad idea), we could just remove them (also a bad idea). endian.h on the other hand lives in a different directory on OS X, still easy to fix. This leaves us with

--- a/linux/platform.h
+++ b/linux/platform.h
@@ -7,12 +7,13 @@
  * Version 3. See the file COPYING for more details.
  */

-#ifndef __linux__
-#error "platform is not Linux"
-#endif
-
 #include <stdint.h>
+
+#ifndef __MACH__
 #include <endian.h>
+#else
+#include <machine/endian.h>
+#endif

 // directly included:
 //#include <stdbool.h> // bool

and

--- a/linux/inject_rtap.c
+++ b/linux/inject_rtap.c
@@ -1,5 +1,11 @@
 #include <stdint.h>
+
+#ifndef __MACH__
 #include <endian.h>
+#else
+#include <machine/endian.h>
+#endif
+
 #include <radiotap.h>

 #include "inject.h"

radiotap (while submodule'd in) also needs this patch:

--- a/platform.h
+++ b/platform.h
@@ -3,7 +3,12 @@
 #ifndef _BSD_SOURCE
 #define _BSD_SOURCE
 #endif
+
+#ifndef __MACH__
 #include <endian.h>
+#else
+#include <machine/endian.h>
+#endif

 #define le16_to_cpu            le16toh
 #define le32_to_cpu            le32toh

Starting from here, things get more interesting, and probably indicate that cross-platform and platform-specific things should be broken out, and dependencies pointed out in the build instructions. Dump:

$ make
gcc -MM -I. -I./core -I./util -I./linux -I./radiotap core/channel.c core/inject.c core/node.c core/wlan_parser.c core/wlan_util.c util/average.c util/util.c linux/inject_rtap.c linux/interface.c linux/netdev.c linux/netl80211.c linux/packet_sock.c linux/platform.c linux/raw_parser.c linux/wpa_ctrl.c radiotap/radiotap.c linux/ifctrl-nl80211.c >.objdeps.mk
linux/netl80211.c:20:10: fatal error: 'netlink/attr.h' file not found
#include <netlink/attr.h>
         ^
1 error generated.
linux/packet_sock.c:16:10: fatal error: 'netpacket/packet.h' file not found
#include <netpacket/packet.h>
         ^
1 error generated.
linux/ifctrl-nl80211.c:19:10: fatal error: 'netlink/attr.h' file not found
#include <netlink/attr.h>
         ^
1 error generated.
Package libnl-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libnl-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libnl-3.0' found
Package libnl-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libnl-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libnl-3.0' found
echo '-std=gnu99 -Wall -Wextra -I. -I./core -I./util -I./linux -I./radiotap -DDEBUG=0 -fPIC ' | cmp -s - .buildflags || echo '-std=gnu99 -Wall -Wextra -I. -I./core -I./util -I./linux -I./radiotap -DDEBUG=0 -fPIC ' > .buildflags
Package libnl-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libnl-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libnl-3.0' found
cc -std=gnu99 -Wall -Wextra -I. -I./core -I./util -I./linux -I./radiotap -DDEBUG=0 -fPIC    -c -o core/channel.o core/channel.c
Package libnl-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libnl-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libnl-3.0' found
cc -std=gnu99 -Wall -Wextra -I. -I./core -I./util -I./linux -I./radiotap -DDEBUG=0 -fPIC    -c -o core/inject.o core/inject.c
core/inject.c:26:15: warning: implicit declaration of function 'htole16' is
      invalid in C99 [-Wimplicit-function-declaration]
        header->fc = htole16(probe_response ? WLAN_FRAME_PROBE_RESP : WL...
                     ^
core/inject.c:37:13: warning: implicit declaration of function 'htole64' is
      invalid in C99 [-Wimplicit-function-declaration]
        bcn->tsf = htole64(tsf);
                   ^
2 warnings generated.
Package libnl-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libnl-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libnl-3.0' found
cc -std=gnu99 -Wall -Wextra -I. -I./core -I./util -I./linux -I./radiotap -DDEBUG=0 -fPIC    -c -o core/node.o core/node.c
Package libnl-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libnl-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libnl-3.0' found
cc -std=gnu99 -Wall -Wextra -I. -I./core -I./util -I./linux -I./radiotap -DDEBUG=0 -fPIC    -c -o core/wlan_parser.o core/wlan_parser.c
core/wlan_parser.c:115:7: warning: implicit declaration of function 'le16toh' is
      invalid in C99 [-Wimplicit-function-declaration]
        fc = le16toh(wh->fc);
             ^
core/wlan_parser.c:269:18: warning: implicit declaration of function 'le64toh'
      is invalid in C99 [-Wimplicit-function-declaration]
                        p->wlan_tsf = le64toh(bc->tsf);
                                      ^
2 warnings generated.
Package libnl-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libnl-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libnl-3.0' found
cc -std=gnu99 -Wall -Wextra -I. -I./core -I./util -I./linux -I./radiotap -DDEBUG=0 -fPIC    -c -o core/wlan_util.o core/wlan_util.c
Package libnl-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libnl-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libnl-3.0' found
cc -std=gnu99 -Wall -Wextra -I. -I./core -I./util -I./linux -I./radiotap -DDEBUG=0 -fPIC    -c -o util/average.o util/average.c
Package libnl-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libnl-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libnl-3.0' found
cc -std=gnu99 -Wall -Wextra -I. -I./core -I./util -I./linux -I./radiotap -DDEBUG=0 -fPIC    -c -o util/util.o util/util.c
Package libnl-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libnl-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libnl-3.0' found
cc -std=gnu99 -Wall -Wextra -I. -I./core -I./util -I./linux -I./radiotap -DDEBUG=0 -fPIC    -c -o linux/inject_rtap.o linux/inject_rtap.c
linux/inject_rtap.c:59:20: warning: implicit declaration of function 'htole16'
      is invalid in C99 [-Wimplicit-function-declaration]
        rtaphdr->it_len = htole16(sizeof(struct inject_radiotap_header));
                          ^
linux/inject_rtap.c:60:24: warning: implicit declaration of function 'htole32'
      is invalid in C99 [-Wimplicit-function-declaration]
        rtaphdr->it_present = htole32(INJECT_RTAP_PRESENT);
                              ^
2 warnings generated.
Package libnl-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libnl-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libnl-3.0' found
cc -std=gnu99 -Wall -Wextra -I. -I./core -I./util -I./linux -I./radiotap -DDEBUG=0 -fPIC    -c -o linux/interface.o linux/interface.c
Package libnl-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libnl-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libnl-3.0' found
cc -std=gnu99 -Wall -Wextra -I. -I./core -I./util -I./linux -I./radiotap -DDEBUG=0 -fPIC    -c -o linux/netdev.o linux/netdev.c
linux/netdev.c:33:16: error: use of undeclared identifier 'SIOCGIFHWADDR'
        if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0) {
                      ^
linux/netdev.c:40:32: error: no member named 'ifr_hwaddr' in 'struct ifreq'
        DBG_PRINT("ARPTYPE %d\n", ifr.ifr_hwaddr.sa_family);
                                  ~~~ ^
./util/util.h:81:60: note: expanded from macro 'DBG_PRINT'
#define DBG_PRINT(...) do { if (DEBUG) printlog(LOG_DEBUG, __VA_ARGS__); } whil...
                                                           ^~~~~~~~~~~
linux/netdev.c:41:13: error: no member named 'ifr_hwaddr' in 'struct ifreq'
        return ifr.ifr_hwaddr.sa_family;
               ~~~ ^
linux/netdev.c:54:16: error: use of undeclared identifier 'SIOCGIFHWADDR'
        if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0) {
                      ^
linux/netdev.c:61:18: error: no member named 'ifr_hwaddr' in 'struct ifreq'
        memcpy(mac, ifr.ifr_hwaddr.sa_data, 6);
                    ~~~ ^
/usr/include/secure/_string.h:65:33: note: expanded from macro 'memcpy'
  __builtin___memcpy_chk (dest, src, len, __darwin_obsz0 (dest))
                                ^~~
5 errors generated.
make: *** [linux/netdev.o] Error 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions