Skip to content

Instantly share code, notes, and snippets.

@heri16
Last active August 30, 2021 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heri16/cd17f3f6ea531c323210cddbaf2912d4 to your computer and use it in GitHub Desktop.
Save heri16/cd17f3f6ea531c323210cddbaf2912d4 to your computer and use it in GitHub Desktop.
Build & Install eixx C++ library

macOS / darwin

Install Dependencies

# Build-time Deps
brew install cmake
# brew install gcc@10
pip3 install gil

# Run-time Deps
brew install boost openssl@1.1

Install Erlang

Only required during build-time (to build eixx library).

Instructions here: https://gist.github.com/heri16/159bc54ec298138a5b4de41c24fc0b69

Build & Install eixx

  1. Build libeixx.a
# export CC=gcc-10 CXX=g++-10
# ${CXX} --version
# Make sure output says "g++-10 (Homebrew GCC 10.3.0) 10.3.0"

git clone https://github.com/saleyn/eixx.git
cd eixx

rm -f .cmake-args.$(hostname)
# echo "CMAKE_CXX_COMPILER=${CXX}" >> .cmake-args.$(hostname)
echo "ENV:BOOST_ROOT=$(brew --prefix boost)" >> .cmake-args.$(hostname)
echo "ENV:OPENSSL_ROOT_DIR=$(brew --prefix openssl)" >> .cmake-args.$(hostname)
echo "DIR:INSTALL=/usr/local/Cellar/@PROJECT@/@VERSION@" >> .cmake-args.$(hostname)
echo "EIXX_MARSHAL_ONLY=OFF" >> .cmake-args.$(hostname)

make distclean
make bootstrap build=Release toolchain=clang
make

# make bootstrap generator=make build=Release toolchain=gcc
# env OPENSSL_ROOT_DIR=$(brew --prefix openssl) BOOST_ROOT=$(brew --prefix boost) make bootstrap generator=make build=Debug prefix=/usr/local/opt/eixx@1.4
# env CC=/usr/local/bin/gcc CXX=/usr/local/bin/g++ OPENSSL_ROOT_DIR=$(brew --prefix openssl) BOOST_ROOT=$(brew --prefix boost) make bootstrap toolchain=gcc build=release prefix=/usr/local/opt verbose=true
# env ERLANG_HOME=$(asdf where erlang) OPENSSL_ROOT_DIR=$(brew --prefix openssl) BOOST_ROOT=$(brew --prefix boost) make bootstrap build=debug prefix=/usr/local/opt verbose=true
# env ERLANG_HOME=$(asdf where erlang) OPENSSL_ROOT_DIR=$(brew --prefix openssl) BOOST_ROOT=$(brew --prefix boost) make bootstrap build=debug prefix=/usr/local/opt verbose=true ERLANG_EI_PATH=$(find $(asdf where erlang)/lib -type d -name 'erl_interface-*')
  1. Install libeixx.a
# Install library to /usr/local/Cellar/eixx/current/lib/libeixx.a
# Install headers to /usr/local/Cellar/eixx/current/include/eixx
make install

# Symlink /usr/local/lib to /usr/local/Cellar/eixx/current/lib
(cd /usr/local/lib && ln -sf ../Cellar/eixx/current/lib/*(-.) .)
(cd /usr/local/lib/pkgconfig && ln -sf ../../Cellar/eixx/current/lib/pkgconfig/*(-.) .)
#(cd /usr/local/lib/pkgconfig && ln -sf ../../opt/openssl@*/lib/pkgconfig/*(-.) .)

ls -l /usr/local/lib/ | grep libeixx.a

If the above does not work, see:

Build Disruptor-Cpp

  1. Build libDisruptor.a
git clone https://github.com/Abc-Arbitrage/Disruptor-cpp.git
cd Disruptor-cpp

mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=release
make
  1. Install libDisruptor.a
# Install library to /usr/local/lib/libDisruptor.a
# Install headers to /usr/local/include/Disruptor
make install

ls -l /usr/local/lib/ | grep libDisruptor.a

Build CppTrader

git clone https://github.com/heri16/CppTrader.git
cd CppTrader
gil update

# export PKG_CONFIG_PATH="$(brew --prefix openssl)/lib/pkgconfig"
export OPENSSL_ROOT_DIR="$(brew --prefix openssl)"
rm -rf ./temp
(cd build && ./unix.sh)

Run CppTrader

  • Command-line Interface:
bin/cpptrader-example-matching_engine
help
  • Network API Interface:
# Start Interactive Elixir Shell on another window/tab:
iex --name iex-demo1@localhost --cookie 123

# Start matching service on another window/tab:
bin/cpptrader-example-matching_node -n test-node@127.0.0.1 -r iex-demo1@127.0.0.1 -c 123 -v trace
# From Interactive Elixir Shell:
pid = self()
port = Port.open({:spawn, "cat"}, [:binary])
GenServer.cast({ :main, :'test-node@127.0.0.1' }, { :atom, 'Char-list String', ["Binary String", pid, port, make_ref()] })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment