choosing_a_boost_python_library_.html 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
  4. <title>Choosing a Boost.Python Library Binary</title>
  5. <link rel="stylesheet" href="../boostbook.css" type="text/css">
  6. <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
  7. <link rel="home" href="../index.html" title="Boost.Python">
  8. <link rel="up" href="../building.html" title="Chapter&#160;2.&#160;Building and Testing">
  9. <link rel="prev" href="configuring_boost_build.html" title="Configuring Boost.Build">
  10. <link rel="next" href="include_issues.html" title="#include Issues">
  11. </head>
  12. <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
  13. <table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/boost.png"></td></tr></table>
  14. <hr>
  15. <div class="spirit-nav">
  16. <a accesskey="p" href="configuring_boost_build.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="include_issues.html"><img src="../images/next.png" alt="Next"></a>
  17. </div>
  18. <div class="section">
  19. <div class="titlepage"><div><div><h3 class="title">
  20. <a name="building.choosing_a_boost_python_library_"></a><a class="link" href="choosing_a_boost_python_library_.html" title="Choosing a Boost.Python Library Binary">Choosing a
  21. Boost.Python Library Binary</a>
  22. </h3></div></div></div>
  23. <div class="toc"><dl class="toc">
  24. <dt><span class="section"><a href="choosing_a_boost_python_library_.html#building.choosing_a_boost_python_library_.the_dynamic_binary">The
  25. Dynamic Binary</a></span></dt>
  26. <dt><span class="section"><a href="choosing_a_boost_python_library_.html#building.choosing_a_boost_python_library_.the_static_binary">The
  27. Static Binary</a></span></dt>
  28. </dl></div>
  29. <p>
  30. If&#8212;instead of letting Boost.Build construct and link with the right libraries
  31. automatically&#8212;you choose to use a pre-built Boost.Python library, you'll
  32. need to think about which one to link with. The Boost.Python binary comes
  33. in both static and dynamic flavors. Take care to choose the right flavor
  34. for your application. <a href="#ftn.building.choosing_a_boost_python_library_.f0" class="footnote" name="building.choosing_a_boost_python_library_.f0"><sup class="footnote">[3]</sup></a>
  35. </p>
  36. <div class="section">
  37. <div class="titlepage"><div><div><h4 class="title">
  38. <a name="building.choosing_a_boost_python_library_.the_dynamic_binary"></a><a class="link" href="choosing_a_boost_python_library_.html#building.choosing_a_boost_python_library_.the_dynamic_binary" title="The Dynamic Binary">The
  39. Dynamic Binary</a>
  40. </h4></div></div></div>
  41. <p>
  42. The dynamic library is the safest and most-versatile choice:
  43. </p>
  44. <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
  45. <li class="listitem">
  46. A single copy of the library code is used by all extension modules
  47. built with a given toolset. <a href="#ftn.building.choosing_a_boost_python_library_.the_dynamic_binary.f0" class="footnote" name="building.choosing_a_boost_python_library_.the_dynamic_binary.f0"><sup class="footnote">[4]</sup></a>
  48. </li>
  49. <li class="listitem">
  50. The library contains a type conversion registry. Because one registry
  51. is shared among all extension modules, instances of a class exposed
  52. to Python in one dynamically-loaded extension module can be passed
  53. to functions exposed in another such module.
  54. </li>
  55. </ul></div>
  56. </div>
  57. <div class="section">
  58. <div class="titlepage"><div><div><h4 class="title">
  59. <a name="building.choosing_a_boost_python_library_.the_static_binary"></a><a class="link" href="choosing_a_boost_python_library_.html#building.choosing_a_boost_python_library_.the_static_binary" title="The Static Binary">The
  60. Static Binary</a>
  61. </h4></div></div></div>
  62. <p>
  63. It might be appropriate to use the static Boost.Python library in any of
  64. the following cases:
  65. </p>
  66. <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
  67. <li class="listitem">
  68. You are <a href="https://docs.python.org/2/extending/extending.html" target="_top">extending</a>
  69. python and the types exposed in your dynamically-loaded extension module
  70. don't need to be used by any other Boost.Python extension modules,
  71. and you don't care if the core library code is duplicated among them.
  72. </li>
  73. <li class="listitem">
  74. You are <a href="https://docs.python.org/2/extending/embedding.html" target="_top">embedding</a>
  75. python in your application and either:
  76. <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
  77. <li class="listitem">
  78. You are targeting a Unix variant OS other than MacOS or AIX,
  79. where the dynamically-loaded extension modules can &#8220;see&#8221;
  80. the Boost.Python library symbols that are part of the executable.
  81. </li>
  82. <li class="listitem">
  83. Or, you have statically linked some Boost.Python extension modules
  84. into your application and you don't care if any dynamically-loaded
  85. Boost.Python extension modules are able to use the types exposed
  86. by your statically-linked extension modules (and vice-versa).
  87. </li>
  88. </ul></div>
  89. </li>
  90. </ul></div>
  91. </div>
  92. <div class="footnotes">
  93. <br><hr style="width:100; text-align:left;margin-left: 0">
  94. <div id="ftn.building.choosing_a_boost_python_library_.f0" class="footnote"><p><a href="#building.choosing_a_boost_python_library_.f0" class="para"><sup class="para">[3] </sup></a>
  95. Information about how to identify the static and dynamic builds of Boost.Python
  96. on <a href="http://boost.org/more/getting_started/windows.html#library-naming" target="_top">Windows</a>
  97. / <a href="http://boost.org/more/getting_started/unix-variants.html#library-naming" target="_top">Unix
  98. variants</a>
  99. </p></div>
  100. <div id="ftn.building.choosing_a_boost_python_library_.the_dynamic_binary.f0" class="footnote"><p><a href="#building.choosing_a_boost_python_library_.the_dynamic_binary.f0" class="para"><sup class="para">[4] </sup></a>
  101. Because of the way most *nix platforms share symbols among dynamically-loaded
  102. objects, I'm not certain that extension modules built with different
  103. compiler toolsets will always use different copies of the Boost.Python
  104. library when loaded into the same Python instance. Not using different
  105. libraries could be a good thing if the compilers have compatible
  106. ABIs, because extension modules built with the two libraries would
  107. be interoperable. Otherwise, it could spell disaster, since an extension
  108. module and the Boost.Python library would have different ideas of
  109. such things as class layout. I would appreciate someone doing the
  110. experiment to find out what happens.
  111. </p></div>
  112. </div>
  113. </div>
  114. <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
  115. <td align="left"></td>
  116. <td align="right"><div class="copyright-footer">Copyright &#169; 2002-2015 David
  117. Abrahams, Stefan Seefeld<br>Copyright &#169; 2002-2015 David Abrahams, Stefan Seefeld<p>
  118. Distributed under the Boost Software License, Version 1.0. (See accompanying
  119. file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
  120. </p>
  121. </div></td>
  122. </tr></table>
  123. <hr>
  124. <div class="spirit-nav">
  125. <a accesskey="p" href="configuring_boost_build.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="include_issues.html"><img src="../images/next.png" alt="Next"></a>
  126. </div>
  127. </body>
  128. </html>