Kazu's Log

Feb 3, 2016

wrk2 on OS X El Capitan

Building wrk2 on OS X El Capitan is not straightforward, due to OpenSSL.

El Capitan has OpenSSL’s libraries, but it doesn’t have corresponding headers. This email from Apple Developer Relations team explains the intention of the mismatch.

As a result, building wrk2 doesn’t succeed.

% make
Building LuaJIT...
HOSTCC    host/minilua.o
..
OK        Successfully built LuaJIT
CC src/wrk.c
In file included from src/wrk.c:3:
src/wrk.h:11:10: fatal error: 'openssl/ssl.h' file not found
#include <openssl/ssl.h>
         ^
1 error generated.
make: *** [obj/wrk.o] Error 1
%

The good news is, OpenSSL is available on Homebrew. After doing brew install openssl, you can specify the location of OpenSSL by passing CC and LDFLAGS through enviromental variables.

% CC='cc -I/usr/local/opt/openssl/include' LDFLAGS='-L/usr/local/opt/openssl/lib' make
Building LuaJIT...
HOSTCC    host/minilua.o
HOSTLINK  host/minilua
ld: warning: directory not found for option '-Ldeps/luajit/src'
DYNASM    host/buildvm_arch.h
...
LUAJIT src/wrk.lua
LINK wrk
%

It does work without LDFLAGS, but in that case, wrk2 includes the headers from Homebrew (1.0.2f as of today), but the binary uses the libraries from OS X (0.9.8). Both of them might be incompatible, so it should be avoided.