Boost logo

Boost Users :

Subject: [Boost-users] [test] manual test suite initialization: linking problems
From: Matthias Vallentin (vallentin_at_[hidden])
Date: 2009-07-16 02:33:52


I am having a linking issue with Boost.Test on my Mac OS X 10.5.
Consider the following example:

    #define BOOST_TEST_DYN_LINK
    #include <boost/test/unit_test.hpp>

    void test() { }

    boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[])
    {
        boost::unit_test::test_suite* ts = BOOST_TEST_SUITE("test suite");
        ts->add(BOOST_TEST_CASE(&test));

        boost::unit_test::framework::master_test_suite().add(ts);

        return 0;
    }

This does not compile with the following command:

    g++ test.cc -L/opt/local/lib -lboost_unit_test_framework-mt

I am getting the following linker error:

    Undefined symbols:
      "_main", referenced from:
          start in crt1.10.5.o
    ld: symbol(s) not found
    collect2: ld returned 1 exit status

It works, however, using the automatic test module definition, e.g.

    #define BOOST_TEST_DYN_LINK
    #define BOOST_TEST_MODULE foo
    #include <boost/test/unit_test.hpp>

and works also when I remove BOOST_TEST_DYN_LINK and compile the program
with the static library:

    g++ test.cc /opt/local/lib/libboost_unit_test_framework-mt.a

But I can't get the first example code above to link. Does anyone see
the problem lurking?

   Matthias

-- 
Matthias Vallentin
vallentin_at_[hidden]
http://www.icir.org/matthias

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net