0

I want to provide my own main function while using Boost.Test. So I have included the following macros:

#define BOOST_TEST_ALTERNATIVE_INIT_API
#define BOOST_TEST_NO_MAIN

My main function looks like this:

int main(int argc, char* argv[])
{
    int exitCode = ::boost::unit_test::unit_test_main(&initialise, argc, argv);

    return exitCode;
}

I have also created the function initialise.

When built on OS X using Xcode 6 the following error is reported:

Undefined symbols for architecture x86_64:
  "boost::unit_test::unit_test_main(bool (*)(), int, char**)", referenced from:
      _main in main.o

I am linking-in the unit test framework library.

Can someone please help resolve the error?

ksl
  • 4,519
  • 11
  • 65
  • 106

1 Answers1

0

There are two possible solutions:

1) Include <boost/test/included/unit_test.hpp> in the test module. This has the effect of building both the test framework and the test module simultaneously.

2) Rebuild the test framework library withBOOST_TEST_NO_MAINand BOOST_TEST_ALTERNATIVE_INIT_API.

According to the documentation the 2nd option is preferred.

ksl
  • 4,519
  • 11
  • 65
  • 106