feelfree
feelfree

Reputation: 11753

static boost.test library and dynamic boost.test library

I have a question related to BOOST.Test framework, and take the following example to illustrate my problem: I build a TestClass library that incorporates all the test classes, and the library can be either static or dynamic. One typical function in this library is as follows:

__declspec(dllexport) HelloWorld()
{

        int i= 2;
        int j= 1;
            BOOST_CHECK(i == j);
        BOOST_CHECK_EQUAL(i,j);
}

Then, I set up an executable program (main.cpp for example) that will invoke this library:

test_suite* init_unit_test_suite( int argc, char* argv[] ) 
{ 
    framework::master_test_suite().add( BOOST_TEST_CASE( &HelloWorld ) ); 

    return 0; 
} 

For both the TestClass library and the executable program, they need BOOST.Test library. This BOOST.Test library I built is static. Then I found:

Upvotes: 3

Views: 688

Answers (1)

mockinterface
mockinterface

Reputation: 14860

Make sure you define the BOOST_TEST_DYN_LINK:

If you opt to link a test module with the prebuilt dynamic library, this usage is called the dynamic library variant of the UTF. This variant requires you to define the flag BOOST_TEST_DYN_LINK either in a makefile or before the header boost/test/unit_test.hpp inclusion.
The dynamic library variant of the UTF

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

Upvotes: 2

Related Questions