Skip to content

Building and installing HHVM on OSX 10.9

craigcarnell edited this page Sep 9, 2014 · 78 revisions

Install with Homebrew

Unfortunately the fully automated Homebrew package is broken at this point. Try the "install by hand" below.

Install by hand

Install homebrew

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"

Tap additional repositories

brew tap homebrew/versions

Install dependencies

brew install freetype gettext cmake git libtool mcrypt oniguruma re2c     \
             autoconf libelf readline automake mysql-connector-c pcre     \
             gd icu4c libmemcached pkg-config tbb imagemagick binutils    \
             curl imap-uw libxslt libevent sqlite homebrew/versions/gcc48 \
             openssl
brew install --build-from-source --cc=gcc-4.8 glog boost

Install some packages that are not (yet) part of homebrew:

brew install \
  https://gist.github.com/slbmeh/9059260/raw/1cbf0f6f5639b4a066395bedb702cdd6bd895d15/libdwarf.rb \
  https://gist.github.com/danslo/6034879/raw/00be8488d2dea232b750ab8207a788032d9135b6/jemallocfb.rb

Get HHVM

git clone --recursive git://github.com/facebook/hhvm.git

Build HHVM

cd hhvm
cmake . \
    -DCMAKE_CXX_COMPILER=$(brew --prefix gcc48)/bin/g++-4.8 \
    -DCMAKE_C_COMPILER=$(brew --prefix gcc48)/bin/gcc-4.8 \
    -DCMAKE_ASM_COMPILER=$(brew --prefix gcc48)/bin/gcc-4.8 \
    -DLIBIBERTY_LIB=$(brew --prefix gcc48)/lib/x86_64/libiberty-4.8.a \
    -DCMAKE_INCLUDE_PATH="/usr/local/include:/usr/include" \
    -DCMAKE_LIBRARY_PATH="/usr/local/lib:/usr/lib" \
    -DLIBEVENT_LIB=$(brew --prefix libevent)/lib/libevent.dylib \
    -DLIBEVENT_INCLUDE_DIR=$(brew --prefix libevent)/include \
    -DICU_INCLUDE_DIR=$(brew --prefix icu4c)/include \
    -DICU_LIBRARY=$(brew --prefix icu4c)/lib/libicuuc.dylib \
    -DICU_I18N_LIBRARY=$(brew --prefix icu4c)/lib/libicui18n.dylib \
    -DICU_DATA_LIBRARY=$(brew --prefix icu4c)/lib/libicudata.dylib \
    -DREADLINE_INCLUDE_DIR=$(brew --prefix readline)/include \
    -DREADLINE_LIBRARY=$(brew --prefix readline)/lib/libreadline.dylib \
    -DCURL_INCLUDE_DIR=$(brew --prefix curl)/include \
    -DCURL_LIBRARY=$(brew --prefix curl)/lib/libcurl.dylib \
    -DBOOST_INCLUDEDIR=$(brew --prefix boost)/include \
    -DBOOST_LIBRARYDIR=$(brew --prefix boost)/lib \
    -DBoost_USE_STATIC_LIBS=ON \
    -DJEMALLOC_INCLUDE_DIR=$(brew --prefix jemallocfb)/include \
    -DJEMALLOC_LIB=$(brew --prefix jemallocfb)/lib/libjemalloc.dylib \
    -DLIBINTL_LIBRARIES=$(brew --prefix gettext)/lib/libintl.dylib \
    -DLIBINTL_INCLUDE_DIR=$(brew --prefix gettext)/include \
    -DLIBDWARF_LIBRARIES=$(brew --prefix libdwarf)/lib/libdwarf.3.dylib \
    -DLIBDWARF_INCLUDE_DIRS=$(brew --prefix libdwarf)/include \
    -DLIBMAGICKWAND_INCLUDE_DIRS=$(brew --prefix imagemagick)/include/ImageMagick-6 \
    -DLIBMAGICKWAND_LIBRARIES=$(brew --prefix imagemagick)/lib/libMagickWand-6.Q16.dylib \
    -DMYSQL_INCLUDE_DIR=$(brew --prefix mysql-connector-c)/include \
    -DMYSQL_LIB=$(brew --prefix mysql-connector-c)/lib \
    -DFREETYPE_INCLUDE_DIRS=$(brew --prefix freetype)/include/freetype2 \
    -DFREETYPE_LIBRARIES=$(brew --prefix freetype)/lib/libfreetype.dylib \
    -DLIBMEMCACHED_LIBRARY=$(brew --prefix libmemcached)/lib \
    -DLIBMEMCACHED_INCLUDE_DIR=$(brew --prefix libmemcached)/include \
    -DLIBELF_LIBRARIES=$(brew --prefix libelf)/lib/libelf.a \
    -DLIBELF_INCLUDE_DIRS=$(brew --prefix libelf)/include/libelf \
    -DLIBGLOG_LIBRARY=$(brew --prefix glog)/lib/libglog.dylib \
    -DLIBGLOG_INCLUDE_DIR=$(brew --prefix glog)/include \
    -DOPENSSL_SSL_LIBRARY=$(brew --prefix openssl)/lib/libssl.dylib \
    -DOPENSSL_INCLUDE_DIR=$(brew --prefix openssl)/include \
    -DOPENSSL_CRYPTO_LIBRARY=$(brew --prefix openssl)/lib/libcrypto.dylib \
    -DPCRE_LIBRARY=$(brew --prefix pcre)/lib \
    -DPCRE_INCLUDE_DIR=$(brew --prefix pcre)/include \
    -DTBB_INSTALL_DIR=$(brew --prefix tbb) \
    -DLIBSQLITE3_INCLUDE_DIR=$(brew --prefix sqlite)/include \
    -DLIBSQLITE3_LIBRARY=$(brew --prefix sqlite)/lib/libsqlite3.0.dylib
make -j4

Trouble shooting

If you see errors like this

Linking CXX executable hhvm
Undefined symbols for architecture x86_64:
  "boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >::maybe_assign(boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > > const&)", referenced from:

during the make -j4 try uninstalling and reinstalling Boost.

Unistall Boost

brew remove boost

Reinstall Boost

brew install --build-from-source --cc=gcc-4.8 boost

Then re-run the make

make -j4
Clone this wiki locally