Skip to content

Instantly share code, notes, and snippets.

@brianv0
Created August 7, 2019 03:40
Show Gist options
  • Save brianv0/4352f6748bd7d51d53d59fc3b2b02c0f to your computer and use it in GitHub Desktop.
Save brianv0/4352f6748bd7d51d53d59fc3b2b02c0f to your computer and use it in GitHub Desktop.
Unable to link in Mac OS X with boost unit_test_framework.
conda create --name boost-test
conda activate boost-test
conda config --env --add channels conda-forge
conda install compilers boost
cat <<EOF > test_Linking_x.cc
#define BOOST_TEST_MODULE Exception_x
#define BOOST_TEST_DYN_LINK
#include "boost/test/unit_test.hpp"
#include "boost/test/output_test_stream.hpp"
namespace test = boost::test_tools;
BOOST_AUTO_TEST_SUITE(ExceptionSuite)
BOOST_AUTO_TEST_CASE(simple) {
test::output_test_stream o;
o << "Hello World";
BOOST_CHECK(!o.is_empty(false));
}
BOOST_AUTO_TEST_SUITE_END()
EOF
g++ -o test_Linking_x.o -c -std=c++14 -g \
-O3 -Wall -Wno-unused-function \
-Iinclude \
-isystem ${CONDA_PREFIX}/include \
test_Linking_x.cc
g++ -o test_Linking_x test_Linking_x.o \
-L${CONDA_PREFIX}/lib/ \
-L/usr/lib/ \
-lboost_unit_test_framework
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment