OLD | NEW |
1 ###################################### | 1 ###################################### |
2 Dynamic Linking and Loading with glibc | 2 Dynamic Linking and Loading with glibc |
3 ###################################### | 3 ###################################### |
4 | 4 |
5 .. contents:: | 5 .. contents:: |
6 :local: | 6 :local: |
7 :backlinks: none | 7 :backlinks: none |
8 :depth: 2 | 8 :depth: 2 |
9 | 9 |
10 Introduction | |
11 ============ | |
12 | |
13 .. Note:: | 10 .. Note:: |
14 :class: caution | 11 :class: caution |
15 | 12 |
16 Portable Native Client currently only supports static linking, and the | 13 Portable Native Client currently only supports static linking, and the |
17 only C library available for it is newlib. This page is only valid for | 14 only C library available for it is newlib. This page is only valid for |
18 Native Client, though PNaCl will eventually support some form of | 15 Native Client, though PNaCl will eventually support some form of |
19 dynamic linking. | 16 dynamic linking. |
20 | 17 |
21 This document describes how to create and deploy dynamically linked and loaded | 18 This document describes how to create and deploy dynamically linked and loaded |
22 applications with the glibc library in the Native Client SDK. Before reading | 19 applications with the glibc library in the Native Client SDK. Before reading |
23 this document, we recommend reading :doc:`Building Native Client Modules | 20 this document, we recommend reading :doc:`Building Native Client Modules |
24 <building>` | 21 <building>` |
25 | 22 |
26 .. _c_libraries: | 23 .. _c_libraries: |
27 | 24 |
28 C standard libraries: glibc and newlib | 25 C standard libraries: glibc and newlib |
29 -------------------------------------- | 26 -------------------------------------- |
30 | 27 |
31 The Native Client SDK comes with two C standard libraries --- glibc and | 28 The Native Client SDK comes with two C standard libraries --- glibc and |
32 newlib. These libraries are described in the table below. | 29 newlib. These libraries are described in the table below. |
33 | 30 |
34 +--------+----------+-------------+--------------------------------------------+ | 31 +-----------------------------------------------------+----------+-------------+ |
35 | Library| Linking | License | Description | | 32 | Library | Linking | License | |
36 +========+==========+=============+============================================+ | 33 +=====================================================+==========+=============+ |
37 | glibc | dynamic | GNU Lesser | glibc is the GNU implementation of the | | 34 |glibc | dynamic | GNU Lesser | |
38 | | or static| General | POSIX_ standard runtime library for the C | | 35 | The GNU implementation of the POSIX_ standard | or static| General | |
39 | | | Public | programming language. Designed for | | 36 | runtime library for the C programming language. | | Public | |
40 | | | License | portability and performance, glibc is one | | 37 | Designed for portability and performance, glibc is | | License | |
41 | | | (LGPL) | of the most popular implementations of the | | 38 | one of the most popular implementations of the C | | (LGPL) | |
42 | | | | C library. It is comprised of a set of | | 39 | library. It is comprised of a set of interdependent| | | |
43 | | | | interdependent libraries including libc, | | 40 | libraries including libc, libpthreads, libdl, and | | | |
44 | | | | libpthreads, libdl, and others. For | | 41 | others. For documentation, FAQs, and additional | | | |
45 | | | | documentation, FAQs, and additional | | 42 | information about glibc, see GLIBC_. | | | |
46 | | | | information about glibc, see GLIBC_ | | 43 +-----------------------------------------------------+----------+-------------+ |
47 +--------+----------+-------------+--------------------------------------------+ | 44 |newlib | static | Berkeley | |
48 | newlib | static | Berkeley | newlib is a C library intended for use in | | 45 | newlib is a C library intended for use in embedded | | Software | |
49 | | | Software | embedded systems. Like glibc, newlib is a | | 46 | systems. Like glibc, newlib is a conglomeration of | | Distribution| |
50 | | | Distribution| conglomeration of several library parts. | | 47 | several libraries. It is available for use under | | (BSD) type | |
51 | | | (BSD) type | It is available for use under BSD-type free| | 48 | BSD-type free software licenses, which generally | | free | |
52 | | | free | software licenses, which generally makes it| | 49 | makes it more suitable to link statically in | | software | |
53 | | | software | more suitable to link statically in | | 50 | commercial, closed-source applications. For | | licenses | |
54 | | | licenses | commercial, closed-source applications. For| | 51 | documentation, FAQs, and additional information | | | |
55 | | | | documentation, FAQs, and additional | | 52 | about newlib, see newlib_. | | | |
56 | | | | information about newlib, see the newlib_ | | 53 +-----------------------------------------------------+----------+-------------+ |
57 | | | | documentation. | | 54 |
58 +--------+----------+-------------+--------------------------------------------+ | |
59 | 55 |
60 For proprietary (closed-source) applications, your options are to either | 56 For proprietary (closed-source) applications, your options are to either |
61 statically link to newlib, or dynamically link to glibc. We recommend | 57 statically link to newlib, or dynamically link to glibc. We recommend |
62 dynamically linking to glibc, for a couple of reasons: | 58 dynamically linking to glibc, for a couple of reasons: |
63 | 59 |
64 * The glibc library is widely distributed (it's included in Linux | 60 * The glibc library is widely distributed (it's included in Linux |
65 distributions), and as such it's mature, hardened, and feature-rich. Your | 61 distributions), and as such it's mature, hardened, and feature-rich. Your |
66 code is more likely to compile out-of-the-box with glibc. | 62 code is more likely to compile out-of-the-box with glibc. |
67 | 63 |
68 * Dynamic loading can provide a big performance benefit for your application if | 64 * Dynamic loading can provide a big performance benefit for your application if |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 **undefined reference to 'dlopen' collect2: ld returned 1 exit status** | 427 **undefined reference to 'dlopen' collect2: ld returned 1 exit status** |
432 This is a linker ordering problem that usually results from improper ordering | 428 This is a linker ordering problem that usually results from improper ordering |
433 of command line flags when linking. Reconfigure your command line string to | 429 of command line flags when linking. Reconfigure your command line string to |
434 list libraries after the -o flag. | 430 list libraries after the -o flag. |
435 | 431 |
436 .. |menu-icon| image:: /images/menu-icon.png | 432 .. |menu-icon| image:: /images/menu-icon.png |
437 .. _objdump: http://en.wikipedia.org/wiki/Objdump | 433 .. _objdump: http://en.wikipedia.org/wiki/Objdump |
438 .. _GLIBC: http://www.gnu.org/software/libc/index.html | 434 .. _GLIBC: http://www.gnu.org/software/libc/index.html |
439 .. _POSIX: http://en.wikipedia.org/wiki/POSIX | 435 .. _POSIX: http://en.wikipedia.org/wiki/POSIX |
440 .. _newlib: http://sourceware.org/newlib/ | 436 .. _newlib: http://sourceware.org/newlib/ |
OLD | NEW |