using.qbk 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. [/
  2. / Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  3. /
  4. / Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. /]
  7. [section:using Using Boost.Asio]
  8. [heading Supported Platforms]
  9. The following platform and compiler combinations are regularly tested:
  10. * Linux using g++ 4.1 or later
  11. * Linux using clang 3.2 or later
  12. * FreeBSD using g++ 4.1 or later
  13. * macOS using Xcode 8 or later
  14. * Win32 using Visual C++ 9.0 or later
  15. * Win32 using g++ 4.1 or later (MinGW)
  16. * Win64 using Visual C++ 9.0 or later
  17. The following platforms may also work:
  18. * AIX
  19. * Android
  20. * HP-UX
  21. * iOS
  22. * NetBSD
  23. * OpenBSD
  24. * QNX Neutrino
  25. * Solaris
  26. * Tru64
  27. * Win32 using Cygwin. (`__USE_W32_SOCKETS` must be defined.)
  28. [heading Dependencies]
  29. The following libraries must be available in order to link programs that use
  30. Boost.Asio:
  31. * Boost.System for the `boost::system::error_code` and
  32. `boost::system::system_error` classes.
  33. * Boost.Coroutine (optional) if you use [link boost_asio.reference.spawn
  34. `spawn()`] to launch coroutines.
  35. * Boost.Regex (optional) if you use any of the [link
  36. boost_asio.reference.read_until `read_until()`] or [link
  37. boost_asio.reference.async_read_until `async_read_until()`] overloads that take
  38. a `boost::regex` parameter.
  39. * [@http://www.openssl.org OpenSSL] (optional) if you use Boost.Asio's SSL
  40. support.
  41. Furthermore, some of the examples also require the Boost.Thread,
  42. Boost.Date_Time or Boost.Serialization libraries.
  43. [note With MSVC or Borland C++ you may want to add `-DBOOST_DATE_TIME_NO_LIB`
  44. and `-DBOOST_REGEX_NO_LIB` to your project settings to disable autolinking of
  45. the Boost.Date_Time and Boost.Regex libraries respectively. Alternatively, you
  46. may choose to build these libraries and link to them.]
  47. [heading Building Boost Libraries]
  48. You may build the subset of Boost libraries required to use Boost.Asio and its
  49. examples by running the following command from the root of the Boost download
  50. package:
  51. [pre
  52. b2 --with-system --with-thread --with-date_time --with-regex --with-serialization stage
  53. ]
  54. This assumes that you have already built `b2`. Consult the Boost.Build
  55. documentation for more details.
  56. [/
  57. [heading Compiling Programs With Boost.Asio]
  58. Consider the following minimal Boost.Asio program [^simple.cpp]:
  59. #include <boost/asio.hpp>
  60. #include <iostream>
  61. #include <ostream>
  62. int main()
  63. {
  64. boost::asio::ip::tcp::iostream s("www.boost.org", "http");
  65. s << "GET / HTTP/1.0\r\n";
  66. s << "Host: www.boost.org\r\n";
  67. s << "\r\n" << std::flush;
  68. std::cout << s.rdbuf();
  69. return 0;
  70. }
  71. The following compiler commands may be used to build the program (note that the
  72. name of the `boost_system` library may vary depending on the compiler version):
  73. [table
  74. [
  75. [OS]
  76. [Compiler]
  77. [Command]
  78. ]
  79. [
  80. [FreeBSD]
  81. [g++]
  82. [[^g++ -I['boost_root] -pthread simple.cpp -L['boost_root]/stage/lib -lboost_system-gcc]]
  83. ]
  84. [
  85. [Linux]
  86. [g++]
  87. [[^g++ -I['boost_root] -pthread simple.cpp -L['boost_root]/stage/lib -lboost_system-gcc41]]
  88. ]
  89. [
  90. [macOS]
  91. [g++]
  92. [[^g++ -I['boost_root] simple.cpp -L['boost_root]/stage/lib -lboost_system]]
  93. ]
  94. [
  95. [Solaris]
  96. [g++]
  97. [[^g++ -I['boost_root] simple.cpp -L['boost_root]/stage/lib -lboost_system -lsocket -lnsl -lpthread]]
  98. ]
  99. [
  100. [Windows]
  101. [MSVC 9.0]
  102. [[^cl /EHsc /GR /MT /I['boost_root] /D_WIN32_WINNT=0x500 simple.cpp /link /libpath:['boost_root]/stage/lib]]
  103. ]
  104. ]
  105. ]
  106. [heading Optional separate compilation]
  107. By default, Boost.Asio is a header-only library. However, some developers may
  108. prefer to build Boost.Asio using separately compiled source code. To do this,
  109. add `#include <boost/asio/impl/src.hpp>` to one (and only one) source file in a
  110. program, then build the program with `BOOST_ASIO_SEPARATE_COMPILATION` defined
  111. in the project\/compiler settings. Alternatively, `BOOST_ASIO_DYN_LINK` may be
  112. defined to build a separately-compiled Boost.Asio as part of a shared library.
  113. If using Boost.Asio's SSL support, you will also need to add `#include
  114. <boost/asio/ssl/impl/src.hpp>`.
  115. [heading Macros]
  116. The macros listed in the table below may be used to control the behaviour of
  117. Boost.Asio.
  118. [table
  119. [[Macro][Description]]
  120. [
  121. [`BOOST_ASIO_ENABLE_BUFFER_DEBUGGING`]
  122. [
  123. Enables Boost.Asio's buffer debugging support, which can help identify when
  124. invalid buffers are used in read or write operations (e.g. if a
  125. std::string object being written is destroyed before the write operation
  126. completes).
  127. When using Microsoft Visual C++ 11.0 or later, this macro is defined
  128. automatically if the compiler's iterator debugging support is enabled,
  129. unless `BOOST_ASIO_DISABLE_BUFFER_DEBUGGING` has been defined.
  130. When using g++, this macro is defined automatically if standard library
  131. debugging is enabled (`_GLIBCXX_DEBUG` is defined), unless
  132. `BOOST_ASIO_DISABLE_BUFFER_DEBUGGING` has been defined.
  133. ]
  134. ]
  135. [
  136. [`BOOST_ASIO_DISABLE_BUFFER_DEBUGGING`]
  137. [
  138. Explictly disables Boost.Asio's buffer debugging support.
  139. ]
  140. ]
  141. [
  142. [`BOOST_ASIO_DISABLE_DEV_POLL`]
  143. [
  144. Explicitly disables [^/dev/poll] support on Solaris, forcing the use of
  145. a `select`-based implementation.
  146. ]
  147. ]
  148. [
  149. [`BOOST_ASIO_DISABLE_EPOLL`]
  150. [
  151. Explicitly disables `epoll` support on Linux, forcing the use of a
  152. `select`-based implementation.
  153. ]
  154. ]
  155. [
  156. [`BOOST_ASIO_DISABLE_EVENTFD`]
  157. [
  158. Explicitly disables `eventfd` support on Linux, forcing the use of a
  159. pipe to interrupt blocked epoll/select system calls.
  160. ]
  161. ]
  162. [
  163. [`BOOST_ASIO_DISABLE_KQUEUE`]
  164. [
  165. Explicitly disables `kqueue` support on macOS and BSD variants,
  166. forcing the use of a `select`-based implementation.
  167. ]
  168. ]
  169. [
  170. [`BOOST_ASIO_DISABLE_IOCP`]
  171. [
  172. Explicitly disables I/O completion ports support on Windows, forcing the
  173. use of a `select`-based implementation.
  174. ]
  175. ]
  176. [
  177. [`BOOST_ASIO_DISABLE_THREADS`]
  178. [
  179. Explicitly disables Boost.Asio's threading support, independent of whether
  180. or not Boost as a whole supports threads.
  181. ]
  182. ]
  183. [
  184. [`BOOST_ASIO_NO_WIN32_LEAN_AND_MEAN`]
  185. [
  186. By default, Boost.Asio will automatically define `WIN32_LEAN_AND_MEAN` when
  187. compiling for Windows, to minimise the number of Windows SDK header files
  188. and features that are included. The presence of
  189. `BOOST_ASIO_NO_WIN32_LEAN_AND_MEAN` prevents `WIN32_LEAN_AND_MEAN` from
  190. being defined.
  191. ]
  192. ]
  193. [
  194. [`BOOST_ASIO_NO_NOMINMAX`]
  195. [
  196. By default, Boost.Asio will automatically define `NOMINMAX` when
  197. compiling for Windows, to suppress the definition of the `min()` and
  198. `max()` macros. The presence of `BOOST_ASIO_NO_NOMINMAX` prevents
  199. `NOMINMAX` from being defined.
  200. ]
  201. ]
  202. [
  203. [`BOOST_ASIO_NO_DEFAULT_LINKED_LIBS`]
  204. [
  205. When compiling for Windows using Microsoft Visual C++ or Borland C++, Boost.Asio
  206. will automatically link in the necessary Windows SDK libraries for sockets
  207. support (i.e. [^ws2_32.lib] and [^mswsock.lib], or [^ws2.lib] when
  208. building for Windows CE). The `BOOST_ASIO_NO_DEFAULT_LINKED_LIBS` macro
  209. prevents these libraries from being linked.
  210. ]
  211. ]
  212. [
  213. [`BOOST_ASIO_ENABLE_CANCELIO`]
  214. [
  215. Enables use of the `CancelIo` function on older versions of Windows. If
  216. not enabled, calls to `cancel()` on a socket object will always fail with
  217. `asio::error::operation_not_supported` when run on Windows XP, Windows
  218. Server 2003, and earlier versions of Windows. When running on Windows
  219. Vista, Windows Server 2008, and later, the `CancelIoEx` function is
  220. always used.
  221. The `CancelIo` function has two issues that should be considered before
  222. enabling its use:
  223. * It will only cancel asynchronous operations that were initiated in the
  224. current thread.
  225. * It can appear to complete without error, but the request
  226. to cancel the unfinished operations may be silently ignored by the
  227. operating system. Whether it works or not seems to depend on the
  228. drivers that are installed.
  229. For portable cancellation, consider using one of the following
  230. alternatives:
  231. * Disable asio's I/O completion port backend by defining
  232. BOOST_ASIO_DISABLE_IOCP.
  233. * Use the socket object's close() function to simultaneously
  234. cancel the outstanding operations and close the socket.
  235. ]
  236. ]
  237. [
  238. [`BOOST_ASIO_NO_TYPEID`]
  239. [
  240. Disables uses of the `typeid` operator in Boost.Asio. Defined
  241. automatically if `BOOST_NO_TYPEID` is defined.
  242. ]
  243. ]
  244. [
  245. [`BOOST_ASIO_HASH_MAP_BUCKETS`]
  246. [
  247. Determines the number of buckets in Boost.Asio's internal `hash_map`
  248. objects. The value should be a comma separated list of prime numbers, in
  249. ascending order. The `hash_map` implementation will automatically
  250. increase the number of buckets as the number of elements in the map
  251. increases.
  252. Some examples:
  253. * Defining `BOOST_ASIO_HASH_MAP_BUCKETS` to `1021` means that the
  254. `hash_map` objects will always contain 1021 buckets, irrespective of
  255. the number of elements in the map.
  256. * Defining `BOOST_ASIO_HASH_MAP_BUCKETS` to `53,389,1543` means that the
  257. `hash_map` objects will initially contain 53 buckets. The number of
  258. buckets will be increased to 389 and then 1543 as elements are added to
  259. the map.
  260. ]
  261. ]
  262. ]
  263. [heading Mailing List]
  264. A mailing list specifically for Boost.Asio may be found on
  265. [@http://sourceforge.net/mail/?group_id=122478 SourceForge.net]. Newsgroup
  266. access is provided via [@http://dir.gmane.org/gmane.comp.lib.boost.asio.user
  267. Gmane].
  268. [heading Wiki]
  269. Users are encouraged to share examples, tips and FAQs on the Boost.Asio wiki,
  270. which is located at [@http://think-async.com/Asio/].
  271. [endsect]