Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/test/doc/components/utf/compilation.html @ 29

Last change on this file since 29 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 8.7 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2<HTML>
3<HEAD>
4<TITLE>The Unit Test Framework compilation</TITLE>
5<LINK rel="stylesheet" type="text/css" href="../../style/btl.css" media="screen">
6<LINK rel="stylesheet" type="text/css" href="../../style/btl-print.css" media="print">
7<META http-equiv="Content-Language" content="en-us">
8<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
9</HEAD>
10<BODY>
11<DIV class="header"> <A href="../../index.html">Boost.Test</A> &gt; <A href="../index.html">Components</A> &gt; <A href="index.html">The
12    Test Framework</A> &gt; <SPAN class="current_article">Compilation</SPAN> </DIV>
13<DIV class="body"> <IMG src="../../btl1.gif" width="252" height="43" alt="Boost Test logo">
14  <H1 class="subtitle">The Unit Test Framework compilation instructions </H1>
15  <P class="first-line-indented">Unlike most boost libraries the Unit Test Framework
16    compilation may require you to go one extra mile. There are several alternative
17    options that you could consider:</P>
18  <UL>
19    <LI><A href="#static_build">Build standalone static library</A> (with possibility
20      to use <A href="#autolinking">auto linking feature</A>)</LI>
21    <LI><A href="#static_build">Build standalone dynamic library</A> (with possibility
22      to use <A href="#autolinking">auto linking feature</A>)</LI>
23    <LI><A href="#included_header">Single header that includes all the implementation
24        files</A></LI>
25    <LI><A href="#include_sources">Include the framework sources directly into
26        your test module project</A></LI>
27  </UL>
28  <P class="first-line-indented">Each option has it's advantages and drawbacks.
29    By default it's recommended to use standalone static library.</P>
30  <H4>Building standalone library<A name="build_standalone"></A></H4>
31  <P class="first-line-indented">The Unit Test Framework is comparatively complicated
32    library and implemented in close to  hundred header and source files.
33    While there exist an alternative option to include the whole implementation
34    directly into your test module, for the long term usage the preferable solution
35    is to build the framework once and reuse it by linking to prebuild library.
36    Depending on your hardware this may save you significant time during compilation
37    and doesn't really require that much effort. </P>
38  <P class="first-line-indented">If you decided to go with standalone
39    library, you first need to build one. There are a varity of make systems
40    that allow you to do that. To name a few: GNU make and
41    similar, all kinds of integrated development environments. Boost preferred
42    solution is Boost.Build system, that is built on top of bjam tool. All make
43    systems require some kind of configuration file that list all files that
44    constitute the library and all the build options. For example makefile that
45    is used by make, Microsoft Visual Studio project file, Jamfile that is used
46    by Boost.Build. For the sake of simplicity lets call this file the makefile.
47    To build a stanalone library following files, that are located in the Boost
48    Test Library source directory, needs to be listed as source files in your
49    makefile:</P>
50  <P class="indented"> <A href="../../../src/compiler_log_formatter.cpp">compiler_log_formatter.cpp</A><BR>
51    <A href="../../../src/exception_safety.cpp">exception_safety.cpp</A><BR>
52    <A href="../../../src/execution_monitor.cpp">execution_monitor.cpp</A><BR>
53    <A href="../../../src/framework.cpp">framework.cpp</A><BR>
54    <A href="../../../src/interaction_based.cpp">interaction_based.cpp</A><BR>
55    <A href="../../../src/logged_expectations.cpp">logged_expectations.cpp</A><BR>
56    <A href="../../../src/plain_report_formatter.cpp">plain_report_formatter.cpp</A><BR>
57    <A href="../../../src/progress_monitor.cpp">progress_monitor.cpp</A><BR>
58    <A href="../../../src/results_collector.cpp">results_collector.cpp</A><BR>
59    <A href="../../../src/results_reporter.cpp">results_reporter.cpp</A><BR>
60    <A href="../../../src/unit_test_log.cpp">unit_test_log.cpp</A><BR>
61    <A href="../../../src/unit_test_main.cpp">unit_test_main.cpp</A><BR>
62    <A href="../../../src/unit_test_monitor.cpp">unit_test_monitor.cpp</A><BR>
63    <A href="../../../src/unit_test_parameters.cpp">unit_test_parameters.cpp</A><BR>
64    <A href="../../../src/unit_test_suite.cpp">unit_test_suite.cpp</A><BR>
65    <A href="../../../src/xml_log_formatter.cpp">xml_log_formatter.cpp</A><BR>
66    <A href="../../../src/xml_report_formatter.cpp">xml_report_formatter.cpp</A></P>
67  <P class="first-line-indented">The <A href="../../../build/Jamfile">Jamfile</A> for
68    use with Boost.Build system is supplied in libs/test/build directory. </P>
69  <H5>Building static library<A name="static_build"></A></H5>
70  <P class="first-line-indented">There are no additional build defines or options
71    required to build static library. Using
72    Boost.build system you could build the static library with a following command
73    from libs/test/build directory:</P>
74  <P class="indented">bjam -sTOOLS=&lt;your-tool-name&gt;  &quot;-sBUILD=&quot;boost_unit_test_framework</P>
75  <P class="first-line-indented">Also on windows you could use this Microsoft
76    Visual Studio .NET <A href="../../../build/msvc71_proj/unit_test_framework.vcproj">project
77    file.</A></P>
78  <H5>Building dynamic library<A name="shared_build"></A></H5>
79  <P class="first-line-indented">To build dynamic library you need to add BOOST_TEST_DYN_LINK
80    to the list of defines in makefile. Using
81    Boost.Build system you could build the dynamic library with a following
82    command from libs/test/build directory:</P>
83  <P class="indented">bjam -sTOOLS=&lt;your-tool-name&gt;  &quot;-sBUILD=&quot; boost_unit_test_framework</P>
84  <P class="first-line-indented">Also on windows you could use this Microsoft
85    Visual Studio .NET <A href="../../../build/msvc71_proj/unit_test_framework_dll.vcproj">project
86    file.</A> </P>
87  <P class="first-line-indented">Note that the same flag BOOST_TEST_DYN_LINK
88    needs to be defined during test module compilation for it to successfully
89    link with dynamic library.
90   </P>
91  <H5>Using autolinking feature<A name="autolinking"></A></H5>
92  <P class="first-line-indented">For the Microsoft family of compilers Boost Test provides an ability to
93    automatically select proper library name and add it to the list of objects
94    to be linked with. By default this feature is on. To disable this feature
95    you should define the flag BOOST_TEST_NO_LIB. More detailes on autolinking
96    feature implementation and configuration you could see <A href="../../../../../more/separate_compilation.html#auto-link">here</A>.</P>
97  <H4>Using &quot;included&quot; option<A name="included_header"></A></H4>
98  <P class="first-line-indented">While building standalone library is preferred
99    solution, some users prefer &quot;quick and dirty&quot; include one. The Unit Test
100    Framework provides an ability to do that. The only change that is required
101    for you to employ it is the path to the header file you include. So the usual
102    include staments:</P>
103<PRE class="code">#<SPAN class="reserv-word">define</SPAN> BOOST_TEST_MAIN ...
104#<SPAN class="reserv-word">include</SPAN> &lt;boost/test/unit_test.hpp&gt;
105
106<SPAN class="comment">...</SPAN></PRE>
107<P>becomes:</P>
108<PRE class="code">#<SPAN class="reserv-word">define</SPAN> BOOST_TEST_MAIN ...
109#<SPAN class="reserv-word">include</SPAN> &lt;boost/test/included/unit_test.hpp&gt;
110
111...</PRE>
112
113<P class="first-line-indented">This way you don't need to link with any prebuild
114  library. The whole Unit Test Framework implementation in included directly
115  into your file. The autolionking feature is disabled also. </P>
116
117  <H4>Including sources directly into test module project<A name="include_sources"></A> </H4>
118  <P class="first-line-indented">Finally you could include all the files listed
119    in <A href="#build_standalone">build standalone library</A> section directly
120    into you test module makefile. Obviosly there is no sence to employ an options
121     for dynamic build since you you are linking with implementation statically. </P>
122</DIV>
123
124<DIV class="footer">
125  <DIV class="footer-body">
126    <P> &copy; <A name="Copyright">Copyright</A> <A href="mailto:boost-test%20at%20emailaccount%20dot%20com%20%28please%20unobscure%29">Gennadiy
127        Rozental</A> 2001-2006. <BR>
128      Distributed under the Boost Software License, Version 1.0. (See accompanying
129      file <A href="../../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A> or copy
130      at <A href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</A>)</P>
131    <P>Revised:
132      <!-- #BeginDate format:Sw1 -->28 February, 2006<!-- #EndDate -->
133    </P>
134  </DIV>
135</DIV>
136</BODY>
137</HTML>
138<!-- #BeginDate format:Sw1 -->28 February, 2006<!-- #EndDate -->
Note: See TracBrowser for help on using the repository browser.