Last active
July 20, 2018 20:24
-
-
Save exklamationmark/90325a57418ab1cfac1aaac1053fce5a to your computer and use it in GitHub Desktop.
Exercism.IO: Hello, World!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This is how I managed to setup Boost and C++ on Ubuntu 16.04. | |
# It's meant for people who are trying to setup for the first time. | |
# I assume you are somewhat familar with Linux, so if any steps seems like magic, please ask for explanation. | |
# Let's work within /tmp/ | |
cd /tmp | |
# This download the file `/tmp/boost_1_67_0.tar.bz2` | |
curl -sLO https://dl.bintray.com/boostorg/release/1.67.0/source/boost_1_67_0.tar.bz2 | |
# Unpack boost's source code | |
tar -xvf boost_1_67_0.tar.bz2 | |
# Move the code to /usr/local/boost_1_67_0. | |
# You will now refer to it when asked for $BOOST_ROOT | |
sudo mv boost_1_67_0 /usr/local/ | |
# Let's build Boost | |
cd /usr/local/boost_1_67_0 | |
./bootstrap.h --with-libraries=all --prefix=/usr/local | |
sudo ./b2 install | |
# and wait for a long time | |
# If you are successful, checkout your /usr/local/lib folder, | |
# You should find a lot of `.a` and `.so` files prefixed with `libboost_` | |
# --------------------------------------------- | |
# now, let's get the hello-world exercise | |
cd ~/exercism | |
exercism fetch cpp hello-world | |
cd cpp/hello-world | |
# ---------- Dynamic linking, skip this if you can find /usr/local/lib/libboost_unit_test_framework.a ---------- | |
# First, edit CMakeLists.txt to turn off static linking (??) | |
sed -i 's/set(Boost_USE_STATIC_LIBS ON)/set(Boost_USE_STATIC_LIBS OFF)/' CMakeLists.txt | |
# Tell boost to link to dynamic library (??) | |
sed -i '/#define BOOST_TEST_MAIN/ a#define BOOST_TEST_DYN_LINK' "$hello_world_test.cpp" | |
# -------------------------------------- | |
# Run cmake | |
cmake -DBOOST_ROOT=/usr/local/boost_1_67_0 -DEXERCISM_RUN_ALL_TESTS=yes . | |
# NOTE: I didn't create the build folder, like the exercism guide. Instead, I want the Makefile to be in the same folder | |
# # Write `hello_world.cpp`: | |
# #include <string> | |
# | |
# namespace hello_world { | |
# | |
# std::string hello() { | |
# return "Fail the test"; | |
# } | |
# | |
# } | |
# run test | |
make | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There' s a typo on line 22. It should read ./bootstrap.sh not ./bootstrap.h