0

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? ...

Community
  • 1
  • 1
user2751691
  • 401
  • 2
  • 10
  • 32
  • Do you see `libboost_unit_test_framework.a` in `/usr/loca/lib`? – Milind Dumbare Mar 19 '15 at 18:41
  • @Miline : Hi, I don't have it in /usr/local/lib. do you know how I can download it please? A version that works on Mac, I could not find it online. Also, I have something called libboost_unit_test_framework-vc71-sgd-1_50.lib and I moved into /usr/local/lib, but it did not work either – user2751691 Mar 19 '15 at 20:30

1 Answers1

0

It is better to use package management software to do this. I highly recommend homebrew.

You can install boost using one command. brew install boost

RealityPC
  • 137
  • 8