Thursday 15 March 2012

c++ - Boost test: #include <boost/test/unit_test.hpp> not found. How to link, config on MAC -


I'm new to promoting the library. I have been promoted by the MacPortes first, and I can locally search for /usr/local/boost_1_57_0/boost/test/unit_test.hpp

then I have an open source Finding and downloading the zip folder URL is here: https://github.com/jsankey/boost.test-examples

Then I have a CD in that download directory And as the make , README said, but it has thrown an error:

  c ++ - main.cpp -lboost_unit_test_framework main.cpp: 3: 10: Fatal Error: 'boost / test / unit_test H Include Not Found # Eepi 'file & lt; Boost / test / unit_test.hpp & gt; ^ 1 error occurred. Make: *** [main] error 1  

Then I just created a hello.cpp file

  g ++ -o hello -lboost_unit_test_framework Ppp  

Yet threw this error:

  Hello. Cpp: 3: 10: Fatal error: 'boost / Test / unit_test.hpp 'file not found # include & lt; Boost / test / unit_test.hpp & gt; ^ 1 error occurred.  

Here is a basic test case of hello.cpp:

  #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MODULE Hello #include & lt; Boost / test / unit_test HPP & gt; Int add (int i, int j) {return i + j; } BOOST_AUTO_TEST_CASE (Cosmic Inorder) {BOOST_CHECK (plus (2, 2) == 5); }  

The existing Makefile is:

  TARGETS = The main suite of fixtures claims: $ (target) exam: $ (goal) $ (adapter) Run -, $ (TARGETS)%:% .cpp $ (CSE) -o $ @ $ ^ -lboost_unit_test_framework run -%:% -. / $ ^ - output_format = xml --log_level = test_suite & gt; $ (^) - report.xml Clear: rm $ (TARGETS) * -report.xml  

Where was I wrong, or what was I supposed to do to compile it? Thanks a lot.

Edit: I received the g ++ -i / usr / local / boost_1_57_0 -i / opt / local / include -l / opt / local / lib hello.cpp-o hello -lboost_unit_test_framework < / Code is used> then it is complaining : ld: -lboost_unit_test_framework does not find the library for blur: error: linker failed with failure failure code 1 (invitations to view -V Use).

I tried downloading boost_unit_test_framework but did not find a source.


No comments:

Post a Comment