configuring_boost.qbk 19 KB

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