I installed the entire boost form its official site, boost 1.57.0
Right now, I just need the boost test library, and I downloaded an example from github https://github.com/jsankey/boost.test-examples
In its makefile, I deleted other targets and only tries the hello.cpp for now.
The makefile is like:
TARGETS=hello
all: $(TARGETS)
test: $(TARGETS) $(addprefix run-,$(TARGETS))
%: %.cpp
$(CXX) -o$@ $^ -lboost_unit_test_framework
run-%: %
-./$^ --output_format=XML --log_level=test_suite > $(^)-report.xml
clean:
rm $(TARGETS) *-report.xml
The boost test file hello.cpp is:
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE Hello
#include <boost/test/unit_test.hpp>
int add(int i, int j)
{
return i + j;
}
BOOST_AUTO_TEST_CASE(universeInOrder)
{
BOOST_CHECK(add(2, 2) == 5);
}
Then I downloaded and installed boost 1.57.0 then used command
sudo tar -C /usr/local -xjvf ~/Downloads/boost_1_57_0.tar.bz2
Then I cd to the directory, and refer to this post, /usr/bin/ld: error: cannot find -lboost_unit_test_framework
I used bash to run export LIBRARY_PATH=/usr/local/lib:$LIBRARY_PATH
Then tried to g++ -ohello /usr/local/lib/libboost_unit_test_framework.a hello.cpp
But it's complaining that libboost_unit_test_framework.a not found.
changedbut libboost_unit_test_framework.a not found in /usr/local/lib/. I tried to search "boost_unit" and there's no file called that on Mac.
So, isn't the boost test library in the downloaded folder? I see the include header files are in .../boost_1_57_0/boost/test/... So, what's wrong and how could I compile and run the basic hello test? Thank you.
I think it is because I did not run the script... ./bootstrap.sh ./b2 ./b2 install
Then that .a file came out. However, I still could not run it. Could someone help please? ...