1[/ 2 Boost.Config 3 4 Copyright (c) 2001 Beman Dawes 5 Copyright (c) 2001 Vesa Karvonen 6 Copyright (c) 2001 John Maddock 7 8 Distributed under the Boost Software License, Version 1.0. 9 (See accompanying file LICENSE_1_0.txt or copy at 10 http://www.boost.org/LICENSE_1_0.txt) 11] 12 13 14[section Configuring Boost for Your Platform] 15 16 17[section Using the default boost configuration] 18 19Boost comes already configured for most common compilers and platforms; you 20should be able to use boost "as is". Since the compiler is configured 21separately from the standard library, the default configuration should work 22even if you replace the compiler's standard library with a third-party 23standard library (like __STL_PORT__). 24 25Using boost "as is" without trying to reconfigure is the recommended method 26for using boost. You can, however, run the configure script if you want to, 27and there are regression tests provided that allow you to test the current 28boost configuration with your particular compiler setup. 29 30Boost library users can request support for additional compilers or platforms 31by visiting our __BOOST_TRACKER__ and submitting a support request. 32 33[endsect] 34 35[section The <boost/config.hpp> header] 36 37Boost library implementations access configuration macros via 38 39 #include ``__BOOST_CONFIG_HEADER__`` 40 41While Boost library users are not required to include that file directly, or 42use those configuration macros, such use is acceptable. The configuration 43macros are documented as to their purpose, usage, and limitations which makes 44them usable by both Boost library and user code. 45 46Boost [link config_info_macros informational] or [link config_helpers helper] 47macros are designed for use by Boost users as well as for our own internal use. 48Note however, that the [link config_features feature test] and 49[link config_defects defect test] macros were designed for internal use by 50Boost libraries, not user code, so they can change at any time (though no 51gratuitous changes are made to them). Boost library problems resulting from 52changes to the configuration macros are caught by the Boost regression tests, 53so the Boost libraries are updated to account for those changes. By contrast, 54Boost library user code can be adversely affected by changes to the macros 55without warning. The best way to keep abreast of changes to the macros used in 56user code is to monitor the discussions on the Boost developers list. 57 58[endsect] 59 60[#config_config_script] 61 62[section Using the configure script] 63 64[important 65This configure script only sets up the Boost headers for use with a particular 66compiler. It has no effect on Boost.Build, or how the libraries are built. 67] 68 69If you know that boost is incorrectly configured for your particular setup, and 70you are on a UNIX like platform, then you may want to try and improve things by 71running the boost configure script. From a shell command prompt you will need to 72cd into ['<boost-root>]`/libs/config/` and type: 73 74[: `sh ./configure` ] 75 76you will see a list of the items being checked as the script works its way 77through the regression tests. Note that the configure script only really 78auto-detects your compiler if it's called g++, c++ or CC. If you are using 79some other compiler you will need to set one or more of the following 80environment variables: 81 82 83[table 84[[Variable][Description ]] 85[[CXX ][The name of the compiler, for example `c++`. ]] 86[[CXXFLAGS][The compiler flags to use, for example `-O2`. ]] 87[[LDFLAGS ][The linker flags to use, for example `-L/mypath`. ]] 88[[LIBS ][Any libraries to link in, for example `-lpthread`.]] 89] 90 91For example to run the configure script with HP aCC, you might use something 92like: 93 94 export CXX="aCC" 95 export CXXFLAGS="-Aa -DAportable -D__HPACC_THREAD_SAFE_RB_TREE \ 96 -DRWSTD_MULTI_THREAD -DRW_MULTI_THREAD -D_REENTRANT -D_THREAD_SAFE" 97 export LDFLAGS="-DAportable" 98 export LIBS="-lpthread" 99 sh ./configure 100 101However you run the configure script, when it finishes you will find a 102new header -`user.hpp`- located in the ['<boost-root>]`/libs/config/` 103directory. [*Note that configure does not install this header into your 104boost include path by default]. This header contains all the options 105generated by the configure script, plus a header-section that contains 106the user settable options from the default version of 107__BOOST_CONFIG_USER_HEADER__ (located under __BOOST_CONFIG_DIR__). 108There are two ways you can use this header: 109 110* [*Option 1:] copy the header into __BOOST_CONFIG_DIR__ so that it replaces 111the default user.hpp provided by boost. This option allows only one 112configure-generated setup; boost developers should avoid this option, 113as it incurs the danger of accidentally committing a configure-modified 114__BOOST_CONFIG_USER_HEADER__ to the svn repository (something you will not 115be thanked for!). 116 117* [*Option 2:] give the header a more memorable name, and place it somewhere 118convenient; then, define the macro `BOOST_USER_CONFIG` to point to it. For 119example create a new sub-directory __BOOST_CONFIG_DIR__ `user/`, and copy 120the header there; for example as `multithread-gcc-config.hpp`. Then, when 121compiling add the command line option: 122`-DBOOST_USER_CONFIG="<boost/config/user/multithread-gcc-config.hpp>"`, and 123boost will use the new configuration header. This option allows you to 124generate more than one configuration header, and to keep them separate 125from the boost source - so that updates to the source do not interfere 126with your configuration. 127 128[endsect] 129 130[#config_user_settable] 131 132[section User settable options] 133 134There are some configuration-options that represent user choices, rather 135than compiler defects or platform specific options. These are listed in 136`<boost/config/user.hpp>` and at the start of a configure-generated `user.hpp` 137header. You can define these on the command line, or by editing 138`<boost/config/user.hpp>`, they are listed in the following table: 139 140 141 142[table 143 144[[Macro ][Description ]] 145 146[[`BOOST_USER_CONFIG`][ 147When defined, it should point to the name of the user configuration file 148to include prior to any boost configuration files. When not defined, 149defaults to [@../../../../boost/config/user.hpp `<boost/config/user.hpp>`]. 150]] 151[[`BOOST_COMPILER_CONFIG`][ 152When defined, it should point to the name of the compiler configuration 153file to use. Defining this cuts out the compiler selection logic, and 154eliminates the dependency on the header containing that logic. For 155example if you are using gcc, then you could define BOOST_COMPILER_CONFIG 156to [@../../../../boost/config/compiler/gcc.hpp `<boost/config/compiler/gcc.hpp>`]. 157]] 158[[`BOOST_STDLIB_CONFIG`][ 159When defined, it should point to the name of the standard library 160configuration file to use. Defining this cuts out the standard library 161selection logic, and eliminates the dependency on the header containing 162that logic. For example if you are using STLport, then you could define 163`BOOST_STDLIB_CONFIG` to 164[@../../../../boost/config/stdlib/stlport.hpp `<boost/config/stdlib/stlport.hpp>`]. 165]] 166[[`BOOST_PLATFORM_CONFIG`][ 167When defined, it should point to the name of the platform configuration 168file to use. Defining this cuts out the platform selection logic, and 169eliminates the dependency on the header containing that logic. For example 170if you are compiling on linux, then you could define `BOOST_PLATFORM_CONFIG` 171to [@../../../../boost/config/platform/linux.hpp `<boost/config/platform/linux.hpp>`]. 172]] 173[[`BOOST_NO_COMPILER_CONFIG`][ 174When defined, no compiler configuration file is selected or included, 175define when the compiler is fully conformant with the standard, or where 176the user header (see `BOOST_USER_CONFIG`), has had any options necessary 177added to it, for example by an autoconf generated configure script. 178]] 179[[`BOOST_NO_STDLIB_CONFIG` ][ 180When defined, no standard library configuration file is selected or included, 181define when the standard library is fully conformant with the standard, or 182where the user header (see `BOOST_USER_CONFIG`), has had any options necessary 183added to it, for example by an autoconf generated configure script. 184]] 185[[`BOOST_NO_PLATFORM_CONFIG` ][ 186When defined, no platform configuration file is selected or included, 187define when the platform is fully conformant with the standard (and has 188no useful extra features), or where the user header (see 189`BOOST_USER_CONFIG`), has had any options necessary added to it, for example 190by an autoconf generated configure script. 191]] 192[[`BOOST_NO_CONFIG` ][ 193Equivalent to defining all of `BOOST_NO_COMPILER_CONFIG`, 194`BOOST_NO_STDLIB_CONFIG` and `BOOST_NO_PLATFORM_CONFIG`. 195]] 196[[`BOOST_STRICT_CONFIG` ][ 197The normal behavior for compiler versions that are newer than the last 198known version, is to assume that they have all the same defects as the 199last known version. By setting this define, then compiler versions that 200are newer than the last known version are assumed to be fully conforming 201with the standard. This is probably most useful for boost developers or 202testers, and for those who want to use boost to test beta compiler versions. 203]] 204[[`BOOST_ASSERT_CONFIG` ][ 205When this flag is set, if the config finds anything unknown, then it will 206stop with a #error rather than continue. Boost regression testers should 207set this define, as should anyone who wants to quickly check whether boost 208is supported on their platform. 209]] 210[[`BOOST_DISABLE_THREADS` ][ 211When defined, disables threading support, even if the compiler in its 212current translation mode supports multiple threads. 213]] 214[[`BOOST_DISABLE_WIN32` ][ 215When defined, disables the use of Win32 specific API's, even when these 216are available. Also has the effect of setting `BOOST_DISABLE_THREADS` unless 217`BOOST_HAS_PTHREADS` is set. This option may be set automatically by the 218config system when it detects that the compiler is in "strict mode". 219]] 220[[`BOOST_DISABLE_ABI_HEADERS`][ 221Stops boost headers from including any prefix/suffix headers that normally 222control things like struct packing and alignment. 223]] 224[[`BOOST_ABI_PREFIX`][ 225A prefix header to include in place of whatever boost.config would normally 226select, any replacement should set up struct packing and alignment options 227as required. 228]] 229[[`BOOST_ABI_SUFFIX` ][ 230A suffix header to include in place of whatever boost.config would normally 231select, any replacement should undo the effects of the prefix header. 232]] 233[[`BOOST_ALL_DYN_LINK`][ 234Forces all libraries that have separate source, to be linked as dll's rather 235than static libraries on Microsoft Windows (this macro is used to turn on 236`__declspec(dllimport)` modifiers, so that the compiler knows which symbols 237to look for in a dll rather than in a static library). 238Note that there may be some libraries that can only be statically linked 239(Boost.Test for example) and others which may only be dynamically linked 240(Boost.Thread for example), in these cases this macro has no effect. 241]] 242[[`BOOST_`['WHATEVER]`_DYN_LINK`][ 243Forces library "whatever" to be linked as a dll rather than a static library 244on Microsoft Windows: replace the ['WHATEVER] part of the macro name with the 245name of the library that you want to dynamically link to, for example use 246`BOOST_DATE_TIME_DYN_LINK` or `BOOST_REGEX_DYN_LINK` etc (this macro is used 247to turn on `__declspec(dllimport)` modifiers, so that the compiler knows 248which symbols to look for in a dll rather than in a static library). 249Note that there may be some libraries that can only be statically linked 250(Boost.Test for example) and others which may only be dynamically linked 251(Boost.Thread for example), in these cases this macro is unsupported. 252]] 253[[`BOOST_ALL_NO_LIB`][ 254Tells the config system not to automatically select which libraries to link 255against. 256Normally if a compiler supports #pragma lib, then the correct library build 257variant will be automatically selected and linked against, simply by the act 258of including one of that library's headers. This macro turns that 259feature off. 260]] 261[[`BOOST_`['WHATEVER]`_NO_LIB`][ 262Tells the config system not to automatically select which library to link 263against for library "whatever", replace ['WHATEVER] in the macro name with the 264name of the library; for example `BOOST_DATE_TIME_NO_LIB` or `BOOST_REGEX_NO_LIB`. 265Normally if a compiler supports `#pragma lib`, then the correct library build 266variant will be automatically selected and linked against, simply by the 267act of including one of that library's headers. This macro turns that 268feature off. 269]] 270[[`BOOST_LIB_DIAGNOSTIC`][ 271Causes the auto-linking code to output diagnostic messages indicating the 272name of the library that is selected for linking. 273]] 274[[`BOOST_LIB_BUILDID`][ 275If you built Boost using the `--buildid` option then set this macro to the same value 276as you passed to bjam. For example if you built using `bjam address-model=64 --buildid=amd64` 277then compile your code with `-DBOOST_LIB_BUILDID=amd64` to ensure the correct libraries 278are selected at link time. 279]] 280[[`BOOST_LIB_TOOLSET`][ 281Overrides the name of the toolset part of the name of library being linked 282to; note if defined this must be defined to a quoted string literal, for 283example "abc". 284]] 285] 286 287[endsect] 288 289[section Advanced configuration usage] 290 291By setting various macros on the compiler command line or by editing 292__BOOST_CONFIG_USER_HEADER__, the boost configuration setup can be optimised 293in a variety of ways. 294 295Boost's configuration is structured so that the user-configuration is 296included first (defaulting to __BOOST_CONFIG_USER_HEADER__ if `BOOST_USER_CONFIG` 297is not defined). This sets up any user-defined policies, and gives the 298user-configuration a chance to influence what happens next. 299 300Next the compiler, standard library, and platform configuration files are 301included. These are included via macros (`BOOST_COMPILER_CONFIG` etc, 302[link config_user_settable see user settable macros]), and if the corresponding 303macro is undefined then a separate header that detects which compiler/standard 304library/platform is in use is included in order to set these. The config 305can be told to ignore these headers altogether if the corresponding 306`BOOST_NO_XXX` macro is set (for example `BOOST_NO_COMPILER_CONFIG` to 307disable including any compiler configuration file - 308[link config_user_settable see user settable macros]). 309 310Finally the boost configuration header, includes __BOOST_CONFIG_SUFFIX_HEADER__; 311this header contains any boiler plate configuration code - for example where one 312boost macro being set implies that another must be set also. 313 314The following usage examples represent just a few of the possibilities: 315 316[section Example 1: creating our own frozen configuration] 317 318Lets suppose that we're building boost with Visual C++ 6, and STLport 4.0. Lets 319suppose also that we don't intend to update our compiler or standard library 320any time soon. In order to avoid breaking dependencies when we update boost, 321we may want to "freeze" our configuration headers, so that we only have to 322rebuild our project if the boost code itself has changed, and not because the 323boost config has been updated for more recent versions of Visual C++ or STLport. 324We'll start by realising that the configuration files in use are: 325[@../../../../boost/config/compiler/visualc.hpp `<boost/config/compiler/visualc.hpp>`] 326for the compiler, 327[@../../../../boost/config/stdlib/stlport.hpp `<boost/config/stdlib/stlport.hpp>`] 328for the standard library, and 329[@../../../../boost/config/platform/win32.hpp `<boost/config/platform/win32.hpp>`] 330for the platform. Next we'll create our own private configuration directory: 331`boost/config/mysetup/`, and copy the configuration files into there. Finally, 332open up __BOOST_CONFIG_USER_HEADER__ and edit the following defines: 333 334 #define BOOST_COMPILER_CONFIG "boost/config/mysetup/visualc.hpp" 335 #define BOOST_STDLIB_CONFIG "boost/config/mysetup/stlport.hpp" 336 #define BOOST_USER_CONFIG "boost/config/mysetup/win32.hpp" 337 338Now when you use boost, its configuration header will go straight to our "frozen" 339versions, and ignore the default versions, you will now be insulated from any 340configuration changes when you update boost. This technique is also useful if 341you want to modify some of the boost configuration files; for example if you are 342working with a beta compiler release not yet supported by boost. 343 344[endsect] 345 346[section Example 2: skipping files that you don't need] 347 348Lets suppose that you're using boost with a compiler that is fully conformant with 349the standard; you're not interested in the fact that older versions of your compiler 350may have had bugs, because you know that your current version does not need any 351configuration macros setting. In a case like this, you can define 352`BOOST_NO_COMPILER_CONFIG` either on the command line, or in __BOOST_CONFIG_USER_HEADER__, 353and miss out the compiler configuration header altogether (actually you miss out 354two headers, one which works out what the compiler is, and one that configures 355boost for it). This has two consequences: the first is that less code has to be 356compiled, and the second that you have removed a dependency on two boost headers. 357 358[endsect] 359 360[section Example 3: using configure script to freeze the boost configuration] 361 362If you are working on a unix-like platform then you can use the configure script to 363generate a "frozen" configuration based on your current compiler setup - 364[link config_config_script see using the configure script for more details]. 365 366[endsect] 367 368[endsect] 369 370[section Testing the boost configuration] 371 372The boost configuration library provides a full set of regression test programs 373under the __BOOST_CONFIG_DIR__ `test/` sub-directory: 374 375 376[table 377[[File][Description]] 378[[`config_info.cpp`][ 379Prints out a detailed description of your compiler/standard library/platform 380setup, plus your current boost configuration. The information provided by this 381program is useful in setting up the boost configuration files. If you report that 382boost is incorrectly configured for your compiler/library/platform then please 383include the output from this program when reporting the changes required. 384]] 385[[`config_test.cpp`][ 386A monolithic test program that includes most of the individual test cases. 387This provides a quick check to see if boost is correctly configured for your 388compiler/library/platform. 389]] 390[[`limits_test.cpp`][ 391Tests your standard library's `std::numeric_limits` implementation (or its boost 392provided replacement if `BOOST_NO_LIMITS` is defined). This test file fails with 393most versions of numeric_limits, mainly due to the way that some compilers 394treat NAN's and infinity. 395]] 396[[`no_*pass.cpp`][ 397Individual compiler defect test files. Each of these should compile, if one 398does not then the corresponding `BOOST_NO_XXX` macro needs to be defined - see 399each test file for specific details. 400]] 401[[`no_*fail.cpp`][ 402Individual compiler defect test files. Each of these should not compile, if 403one does then the corresponding `BOOST_NO_XXX` macro is defined when it need 404not be - see each test file for specific details. 405]] 406[[`has_*pass.cpp`][ 407Individual feature test files. If one of these does not compile then the 408corresponding `BOOST_HAS_XXX` macro is defined when it should not be - see 409each test file for specific details. 410]] 411[[`has_*fail.cpp`][ 412Individual feature test files. If one of these does compile then the 413corresponding `BOOST_HAS_XXX` macro can be safely defined - see each test 414file for specific details. 415]] 416] 417 418Although you can run the configuration regression tests as individual test 419files, there are rather a lot of them, so there are a couple of shortcuts to 420help you out: 421 422Alternatively you can run the configure script like this: 423 424[: `./configure --enable-test`] 425 426in which case the script will test the current configuration rather than 427creating a new one from scratch. 428 429If you are reporting the results of these tests for a new 430platform/library/compiler then please include a log of the full compiler output, 431the output from `config_info.cpp`, and the pass/fail test results. 432 433 434[endsect] 435 436[endsect] 437 438