cisco/joy

Cannot build cleanly on OS X El Capitan

Closed this issue · 4 comments

I'm running OS X El Capitan (10.11.1), and I can't build cleanly.

My environment consists of:

  • OS X 10.11.1
  • Xcode 7.2 (and its command-line tools)
  • clang Apple LLVM version 7.0.2 (clang-700.1.81)

On the first attempt, I get missing references to OpenSSL include headers and the system endian header. The former is because Apple deprecated the use of OpenSSL [1], and the latter seems to be a platform-specific location thing.

$ make
cd src; /Applications/Xcode.app/Contents/Developer/usr/bin/make
Makefile variables:
sysname=DARWIN
version=1.0
CWD=src
gcc -Wall -Wno-deprecated-declarations -g -O3   -mmacosx-version-min=10.5 -DDARWIN=1 -DVERSION=\"1.0\" -o pcap2flow  pcap2flow.c p2f.c config.c osdetect.c anon.c pkt_proc.c nfv9.c tls.c classify.c radix_trie.c hdr_dsc.c procwatch.c addr_attr.c addr.c wht.c -lpcap     -lm       -lcrypto
In file included from pcap2flow.c:69:
./anon.h:59:10: fatal error: 'openssl/aes.h' file not found
#include <openssl/aes.h>
         ^
1 error generated.
In file included from p2f.c:54:
./anon.h:59:10: fatal error: 'openssl/aes.h' file not found
#include <openssl/aes.h>
         ^
1 error generated.
In file included from config.c:42:
./anon.h:59:10: fatal error: 'openssl/aes.h' file not found
#include <openssl/aes.h>
         ^
1 error generated.
anon.c:58:10: fatal error: 'openssl/aes.h' file not found
#include <openssl/aes.h>
         ^
1 error generated.
In file included from pkt_proc.c:49:
./pkt.h:44:10: fatal error: 'endian.h' file not found
#include <endian.h>
         ^
1 error generated.
procwatch.c:73:10: fatal error: 'openssl/sha.h' file not found
#include <openssl/sha.h>
         ^
1 error generated.
make[1]: *** [pcap2flow] Error 1
make: *** [pcap2flow] Error 2

On my second attempt, I configured CFLAGS in src/Makefile to point to my local OpenSSL installation, but picked up two new errors: first one related to the inlining of wht_init (I think this might be compiler-specific), and a second one concerning the location of endian.h (I think this is platform-specific).

cd src; /Applications/Xcode.app/Contents/Developer/usr/bin/make
Makefile variables:
sysname=DARWIN
version=1.0
CWD=src
gcc -Wall -Wno-deprecated-declarations -g -O3   -I/usr/local/opt/openssl/include -mmacosx-version-min=10.5 -DDARWIN=1 -DVERSION=\"1.0\" -o pcap2flow  pcap2flow.c p2f.c config.c osdetect.c anon.c pkt_proc.c nfv9.c tls.c classify.c radix_trie.c hdr_dsc.c procwatch.c addr_attr.c addr.c wht.c -lpcap     -lm       -lcrypto
p2f.c:1118:66: warning: format specifies type 'long' but the argument has type '__darwin_suseconds_t' (aka 'int') [-Wformat]
  fprintf(output, "\t\t\t\"ts\": %ld.%06ld,\n", ts_start.tv_sec, ts_start.tv_usec);
                                     ~~~~~                       ^~~~~~~~~~~~~~~~
                                     %06d
p2f.c:1119:64: warning: format specifies type 'long' but the argument has type '__darwin_suseconds_t' (aka 'int') [-Wformat]
  fprintf(output, "\t\t\t\"te\": %ld.%06ld,\n", ts_end.tv_sec, ts_end.tv_usec);
                                     ~~~~~                     ^~~~~~~~~~~~~~
                                     %06d
In file included from p2f.c:52:
In file included from ./p2f.h:56:
./wht.h:53:13: warning: inline function 'wht_init' is not defined [-Wundefined-inline]
inline void wht_init(struct wht *wht);
            ^
p2f.c:423:3: note: used here
  wht_init(&record->wht);
  ^
3 warnings generated.
In file included from pkt_proc.c:49:
./pkt.h:44:10: fatal error: 'endian.h' file not found
#include <endian.h>
         ^
1 error generated.
make[1]: *** [pcap2flow] Error 1
make: *** [pcap2flow] Error 2

On my third attempt, I took the inline function from src/wht.c, and replaced the definition in src/wht.h with the function itself. I changed src/pkt.h to look for machine/endian.h.

I ran into a new error regarding radix_trie_node_add_flag_to_all_leaves:

cd src; /Applications/Xcode.app/Contents/Developer/usr/bin/make
Makefile variables:
sysname=DARWIN
version=1.0
CWD=src
gcc -Wall -Wno-deprecated-declarations -g -O3   -I/usr/local/opt/openssl/include -mmacosx-version-min=10.5 -DDARWIN=1 -DVERSION=\"1.0\" -o pcap2flow  pcap2flow.c p2f.c config.c osdetect.c anon.c pkt_proc.c nfv9.c tls.c classify.c radix_trie.c hdr_dsc.c procwatch.c addr_attr.c addr.c wht.c -lpcap     -lm       -lcrypto
p2f.c:1118:66: warning: format specifies type 'long' but the argument has type '__darwin_suseconds_t' (aka 'int') [-Wformat]
  fprintf(output, "\t\t\t\"ts\": %ld.%06ld,\n", ts_start.tv_sec, ts_start.tv_usec);
                                     ~~~~~                       ^~~~~~~~~~~~~~~~
                                     %06d
p2f.c:1119:64: warning: format specifies type 'long' but the argument has type '__darwin_suseconds_t' (aka 'int') [-Wformat]
  fprintf(output, "\t\t\t\"te\": %ld.%06ld,\n", ts_end.tv_sec, ts_end.tv_usec);
                                     ~~~~~                     ^~~~~~~~~~~~~~
                                     %06d
2 warnings generated.
Undefined symbols for architecture x86_64:
  "_radix_trie_node_add_flag_to_all_leaves", referenced from:
      _radix_trie_add_subnet in radix_trie-37d328.o
      _radix_trie_unit_test in radix_trie-37d328.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [pcap2flow] Error 1
make: *** [pcap2flow] Error 2

It seemed to be another inlining issue, but not quite. At this point, I'm stumped.

Hi oogali,

the Mac OSX coverage so far is 10.9.5 - sorry for the trouble with your up-to-date Mac. Thanks for the detailed writeup on the issues with 10.10. I need to upgrade to 10.10 to test this. I'm at FloCon this week, so that will need to wait for tonight or tomorrow morning.

David

A quick update on this: I fixed all of the issues except for the missing AES files, and I'm upgrading my mac osx system now. Hopefully there is a compatible version of the AES-128 cipher on that system, so that last fix will just be a matter of finding it and changing the include (and possibly the function invocation) .

David

@davidmcgrew This builds cleanly for me now.

$ make
cd src; /Applications/Xcode.app/Contents/Developer/usr/bin/make
Makefile variables:
sysname=DARWIN
version=1.0
CWD=src
gcc -Wall -Wno-deprecated-declarations -g -O3   -mmacosx-version-min=10.5 -DDARWIN=1 -DVERSION=\"1.0\" -o pcap2flow  pcap2flow.c p2f.c config.c osdetect.c anon.c pkt_proc.c nfv9.c tls.c classify.c radix_trie.c hdr_dsc.c procwatch.c addr_attr.c addr.c wht.c -lpcap     -lm       -lcrypto
strip pcap2flow
gcc -Wall -Wno-deprecated-declarations -g -O3   -mmacosx-version-min=10.5 -DDARWIN=1 -DVERSION=\"1.0\" -o jfd-anon  jfd-anon.c anon.c addr.c -lpcap     -lm       -lcrypto
gcc -Wall -Wno-deprecated-declarations -g -O3   -mmacosx-version-min=10.5 -DDARWIN=1 -DVERSION=\"1.0\" -o unit_test  unit_test.c p2f.c config.c osdetect.c anon.c pkt_proc.c nfv9.c tls.c classify.c radix_trie.c hdr_dsc.c procwatch.c addr_attr.c addr.c wht.c -lpcap     -lm       -lcrypto
cp src/pcap2flow .

Great, glad to hear it!