| OLD | NEW |
| 1 {{+bindTo:partials.standard_nacl_article}} | 1 {{+bindTo:partials.standard_nacl_article}} |
| 2 | 2 |
| 3 <section id="dynamic-linking-and-loading-with-glibc"> | 3 <section id="dynamic-linking-and-loading-with-glibc"> |
| 4 <h1 id="dynamic-linking-and-loading-with-glibc">Dynamic Linking and Loading with
glibc</h1> | 4 <h1 id="dynamic-linking-and-loading-with-glibc">Dynamic Linking and Loading with
glibc</h1> |
| 5 <div class="contents local" id="contents" style="display: none"> | 5 <div class="contents local" id="contents" style="display: none"> |
| 6 <ul class="small-gap"> | 6 <ul class="small-gap"> |
| 7 <li><p class="first"><a class="reference internal" href="#introduction" id="id1"
>Introduction</a></p> | 7 <li><a class="reference internal" href="#c-standard-libraries-glibc-and-newlib"
id="id1">C standard libraries: glibc and newlib</a></li> |
| 8 <li><a class="reference internal" href="#sdk-toolchains" id="id2">SDK toolchains
</a></li> |
| 9 <li><p class="first"><a class="reference internal" href="#specifying-and-deliver
ing-shared-libraries" id="id3">Specifying and delivering shared libraries</a></p
> |
| 8 <ul class="small-gap"> | 10 <ul class="small-gap"> |
| 9 <li><a class="reference internal" href="#c-standard-libraries-glibc-and-newlib"
id="id2">C standard libraries: glibc and newlib</a></li> | 11 <li><a class="reference internal" href="#building-a-dynamically-linked-applicati
on" id="id4">Building a dynamically linked application</a></li> |
| 10 <li><a class="reference internal" href="#sdk-toolchains" id="id3">SDK toolchains
</a></li> | 12 <li><a class="reference internal" href="#generating-a-native-client-manifest-fil
e-for-a-dynamically-linked-application" id="id5">Generating a Native Client mani
fest file for a dynamically linked application</a></li> |
| 11 <li><a class="reference internal" href="#specifying-and-delivering-shared-librar
ies" id="id4">Specifying and delivering shared libraries</a></li> | 13 <li><a class="reference internal" href="#deploying-a-dynamically-linked-applicat
ion" id="id6">Deploying a dynamically linked application</a></li> |
| 14 <li><a class="reference internal" href="#opening-a-shared-library-at-runtime" id
="id7">Opening a shared library at runtime</a></li> |
| 15 <li><a class="reference internal" href="#troubleshooting" id="id8">Troubleshooti
ng</a></li> |
| 12 </ul> | 16 </ul> |
| 13 </li> | 17 </li> |
| 14 <li><a class="reference internal" href="#building-a-dynamically-linked-applicati
on" id="id5">Building a dynamically linked application</a></li> | |
| 15 <li><a class="reference internal" href="#generating-a-native-client-manifest-fil
e-for-a-dynamically-linked-application" id="id6">Generating a Native Client mani
fest file for a dynamically linked application</a></li> | |
| 16 <li><a class="reference internal" href="#deploying-a-dynamically-linked-applicat
ion" id="id7">Deploying a dynamically linked application</a></li> | |
| 17 <li><a class="reference internal" href="#opening-a-shared-library-at-runtime" id
="id8">Opening a shared library at runtime</a></li> | |
| 18 <li><a class="reference internal" href="#troubleshooting" id="id9">Troubleshooti
ng</a></li> | |
| 19 </ul> | 18 </ul> |
| 20 | 19 |
| 21 </div><h2 id="introduction">Introduction</h2> | 20 </div><aside class="caution"> |
| 22 <aside class="caution"> | |
| 23 Portable Native Client currently only supports static linking, and the | 21 Portable Native Client currently only supports static linking, and the |
| 24 only C library available for it is newlib. This page is only valid for | 22 only C library available for it is newlib. This page is only valid for |
| 25 Native Client, though PNaCl will eventually support some form of | 23 Native Client, though PNaCl will eventually support some form of |
| 26 dynamic linking. | 24 dynamic linking. |
| 27 </aside> | 25 </aside> |
| 28 <p>This document describes how to create and deploy dynamically linked and loade
d | 26 <p>This document describes how to create and deploy dynamically linked and loade
d |
| 29 applications with the glibc library in the Native Client SDK. Before reading | 27 applications with the glibc library in the Native Client SDK. Before reading |
| 30 this document, we recommend reading <a class="reference internal" href="/native-
client/devguide/devcycle/building.html"><em>Building Native Client Modules</em><
/a></p> | 28 this document, we recommend reading <a class="reference internal" href="/native-
client/devguide/devcycle/building.html"><em>Building Native Client Modules</em><
/a></p> |
| 31 <h3 id="c-standard-libraries-glibc-and-newlib"><span id="c-libraries"></span>C s
tandard libraries: glibc and newlib</h3> | 29 <h2 id="c-standard-libraries-glibc-and-newlib"><span id="c-libraries"></span>C s
tandard libraries: glibc and newlib</h2> |
| 32 <p>The Native Client SDK comes with two C standard libraries — glibc and | 30 <p>The Native Client SDK comes with two C standard libraries — glibc and |
| 33 newlib. These libraries are described in the table below.</p> | 31 newlib. These libraries are described in the table below.</p> |
| 34 <table border="1" class="docutils"> | 32 <table border="1" class="docutils"> |
| 35 <colgroup> | 33 <colgroup> |
| 36 </colgroup> | 34 </colgroup> |
| 37 <thead valign="bottom"> | 35 <thead valign="bottom"> |
| 38 <tr class="row-odd"><th class="head">Library</th> | 36 <tr class="row-odd"><th class="head">Library</th> |
| 39 <th class="head">Linking</th> | 37 <th class="head">Linking</th> |
| 40 <th class="head">License</th> | 38 <th class="head">License</th> |
| 41 <th class="head">Description</th> | |
| 42 </tr> | 39 </tr> |
| 43 </thead> | 40 </thead> |
| 44 <tbody valign="top"> | 41 <tbody valign="top"> |
| 45 <tr class="row-even"><td>glibc</td> | 42 <tr class="row-even"><td><dl class="first last docutils"> |
| 43 <dt>glibc</dt> |
| 44 <dd>The GNU implementation of the <a class="reference external" href="http://en.
wikipedia.org/wiki/POSIX">POSIX</a> standard |
| 45 runtime library for the C programming language. |
| 46 Designed for portability and performance, glibc is |
| 47 one of the most popular implementations of the C |
| 48 library. It is comprised of a set of interdependent |
| 49 libraries including libc, libpthreads, libdl, and |
| 50 others. For documentation, FAQs, and additional |
| 51 information about glibc, see <a class="reference external" href="http://www.gnu.
org/software/libc/index.html">GLIBC</a>.</dd> |
| 52 </dl> |
| 53 </td> |
| 46 <td>dynamic | 54 <td>dynamic |
| 47 or static</td> | 55 or static</td> |
| 48 <td>GNU Lesser | 56 <td>GNU Lesser |
| 49 General | 57 General |
| 50 Public | 58 Public |
| 51 License | 59 License |
| 52 (LGPL)</td> | 60 (LGPL)</td> |
| 53 <td>glibc is the GNU implementation of the | |
| 54 <a class="reference external" href="http://en.wikipedia.org/wiki/POSIX">POSIX</a
> standard runtime library for the C | |
| 55 programming language. Designed for | |
| 56 portability and performance, glibc is one | |
| 57 of the most popular implementations of the | |
| 58 C library. It is comprised of a set of | |
| 59 interdependent libraries including libc, | |
| 60 libpthreads, libdl, and others. For | |
| 61 documentation, FAQs, and additional | |
| 62 information about glibc, see <a class="reference external" href="http://www.gnu.
org/software/libc/index.html">GLIBC</a></td> | |
| 63 </tr> | 61 </tr> |
| 64 <tr class="row-odd"><td>newlib</td> | 62 <tr class="row-odd"><td><dl class="first last docutils"> |
| 63 <dt>newlib</dt> |
| 64 <dd>newlib is a C library intended for use in embedded |
| 65 systems. Like glibc, newlib is a conglomeration of |
| 66 several libraries. It is available for use under |
| 67 BSD-type free software licenses, which generally |
| 68 makes it more suitable to link statically in |
| 69 commercial, closed-source applications. For |
| 70 documentation, FAQs, and additional information |
| 71 about newlib, see <a class="reference external" href="http://sourceware.org/newl
ib/">newlib</a>.</dd> |
| 72 </dl> |
| 73 </td> |
| 65 <td>static</td> | 74 <td>static</td> |
| 66 <td>Berkeley | 75 <td>Berkeley |
| 67 Software | 76 Software |
| 68 Distribution | 77 Distribution |
| 69 (BSD) type | 78 (BSD) type |
| 70 free | 79 free |
| 71 software | 80 software |
| 72 licenses</td> | 81 licenses</td> |
| 73 <td>newlib is a C library intended for use in | |
| 74 embedded systems. Like glibc, newlib is a | |
| 75 conglomeration of several library parts. | |
| 76 It is available for use under BSD-type free | |
| 77 software licenses, which generally makes it | |
| 78 more suitable to link statically in | |
| 79 commercial, closed-source applications. For | |
| 80 documentation, FAQs, and additional | |
| 81 information about newlib, see the <a class="reference external" href="http://sou
rceware.org/newlib/">newlib</a> | |
| 82 documentation.</td> | |
| 83 </tr> | 82 </tr> |
| 84 </tbody> | 83 </tbody> |
| 85 </table> | 84 </table> |
| 86 <p>For proprietary (closed-source) applications, your options are to either | 85 <p>For proprietary (closed-source) applications, your options are to either |
| 87 statically link to newlib, or dynamically link to glibc. We recommend | 86 statically link to newlib, or dynamically link to glibc. We recommend |
| 88 dynamically linking to glibc, for a couple of reasons:</p> | 87 dynamically linking to glibc, for a couple of reasons:</p> |
| 89 <ul class="small-gap"> | 88 <ul class="small-gap"> |
| 90 <li>The glibc library is widely distributed (it’s included in Linux | 89 <li>The glibc library is widely distributed (it’s included in Linux |
| 91 distributions), and as such it’s mature, hardened, and feature-rich. Your | 90 distributions), and as such it’s mature, hardened, and feature-rich. Your |
| 92 code is more likely to compile out-of-the-box with glibc.</li> | 91 code is more likely to compile out-of-the-box with glibc.</li> |
| (...skipping 27 matching lines...) Expand all Loading... |
| 120 <p><strong>Notes:</strong></p> | 119 <p><strong>Notes:</strong></p> |
| 121 <ul class="small-gap"> | 120 <ul class="small-gap"> |
| 122 <li>Static linking with glibc is rarely used. Use this feature with caution.</li
> | 121 <li>Static linking with glibc is rarely used. Use this feature with caution.</li
> |
| 123 <li>The standard C++ runtime in Native Client is provided by libstdc++; this | 122 <li>The standard C++ runtime in Native Client is provided by libstdc++; this |
| 124 library is independent from and layered on top of glibc. Because of | 123 library is independent from and layered on top of glibc. Because of |
| 125 licensing restrictions, libstdc++ must be statically linked for commercial | 124 licensing restrictions, libstdc++ must be statically linked for commercial |
| 126 uses, even if the rest of an application is dynamically linked.</li> | 125 uses, even if the rest of an application is dynamically linked.</li> |
| 127 </ul> | 126 </ul> |
| 128 | 127 |
| 129 </aside> | 128 </aside> |
| 130 <h3 id="sdk-toolchains">SDK toolchains</h3> | 129 <h2 id="sdk-toolchains">SDK toolchains</h2> |
| 131 <p>The Native Client SDK contains multiple toolchains, which are differentiated
by | 130 <p>The Native Client SDK contains multiple toolchains, which are differentiated
by |
| 132 <a class="reference internal" href="/native-client/devguide/devcycle/building.ht
ml#target-architectures"><em>target architecture</em></a> and C library:</p> | 131 <a class="reference internal" href="/native-client/devguide/devcycle/building.ht
ml#target-architectures"><em>target architecture</em></a> and C library:</p> |
| 133 <table border="1" class="docutils"> | 132 <table border="1" class="docutils"> |
| 134 <colgroup> | 133 <colgroup> |
| 135 </colgroup> | 134 </colgroup> |
| 136 <thead valign="bottom"> | 135 <thead valign="bottom"> |
| 137 <tr class="row-odd"><th class="head">Target architecture</th> | 136 <tr class="row-odd"><th class="head">Target architecture</th> |
| 138 <th class="head">C library</th> | 137 <th class="head">C library</th> |
| 139 <th class="head">Toolchain directory</th> | 138 <th class="head">Toolchain directory</th> |
| 140 </tr> | 139 </tr> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 161 <p>In the directories listed above, <platform> is the platform of your dev
elopment | 160 <p>In the directories listed above, <platform> is the platform of your dev
elopment |
| 162 machine (i.e., win, mac, or linux). For example, in the Windows SDK, the x86 | 161 machine (i.e., win, mac, or linux). For example, in the Windows SDK, the x86 |
| 163 toolchain that uses glibc is in <code>toolchain/win_x86_glibc</code>.</p> | 162 toolchain that uses glibc is in <code>toolchain/win_x86_glibc</code>.</p> |
| 164 <aside class="note"> | 163 <aside class="note"> |
| 165 <strong>Note:</strong> The ARM and PNaCl toolchains are currently restricted to
newlib. | 164 <strong>Note:</strong> The ARM and PNaCl toolchains are currently restricted to
newlib. |
| 166 </aside> | 165 </aside> |
| 167 <p>To use the glibc library and dynamic linking in your application, you <strong
>must</strong> | 166 <p>To use the glibc library and dynamic linking in your application, you <strong
>must</strong> |
| 168 use a glibc toolchain. (Currently the only glibc toolchain is | 167 use a glibc toolchain. (Currently the only glibc toolchain is |
| 169 <code><platform>_x86_glibc</code>.) Note that you must build all code in y
our application | 168 <code><platform>_x86_glibc</code>.) Note that you must build all code in y
our application |
| 170 with one toolchain. Code from multiple toolchains cannot be mixed.</p> | 169 with one toolchain. Code from multiple toolchains cannot be mixed.</p> |
| 171 <h3 id="specifying-and-delivering-shared-libraries">Specifying and delivering sh
ared libraries</h3> | 170 <h2 id="specifying-and-delivering-shared-libraries">Specifying and delivering sh
ared libraries</h2> |
| 172 <p>One significant difference between newlib and glibc applications is that glib
c | 171 <p>One significant difference between newlib and glibc applications is that glib
c |
| 173 applications must explicitly list and deploy the shared libraries that they | 172 applications must explicitly list and deploy the shared libraries that they |
| 174 use.</p> | 173 use.</p> |
| 175 <p>In a desktop environment, when the user launches a dynamically linked | 174 <p>In a desktop environment, when the user launches a dynamically linked |
| 176 application, the operating system’s program loader determines the set of | 175 application, the operating system’s program loader determines the set of |
| 177 libraries the application requires by reading explicit inter-module | 176 libraries the application requires by reading explicit inter-module |
| 178 dependencies from executable file headers, and loads the required libraries | 177 dependencies from executable file headers, and loads the required libraries |
| 179 into the address space of the application process. Typically the required | 178 into the address space of the application process. Typically the required |
| 180 libraries will have been installed on the system as a part of the application
217;s | 179 libraries will have been installed on the system as a part of the application
217;s |
| 181 installation process. Often the desktop application developer doesn’t know
or | 180 installation process. Often the desktop application developer doesn’t know
or |
| 182 think about the libraries that are required by an application, as those details | 181 think about the libraries that are required by an application, as those details |
| 183 are taken care of by the user’s operating system.</p> | 182 are taken care of by the user’s operating system.</p> |
| 184 <p>In the Native Client sandbox, dynamic linking can’t rely in the same wa
y on the | 183 <p>In the Native Client sandbox, dynamic linking can’t rely in the same wa
y on the |
| 185 operating system or the local file system. Instead, the application developer | 184 operating system or the local file system. Instead, the application developer |
| 186 must identify the set of libraries that are required by an application, list | 185 must identify the set of libraries that are required by an application, list |
| 187 those libraries in a Native Client <a class="reference internal" href="/native-c
lient/devguide/coding/application-structure.html#manifest-file"><em>manifest fil
e</em></a>, and | 186 those libraries in a Native Client <a class="reference internal" href="/native-c
lient/devguide/coding/application-structure.html#manifest-file"><em>manifest fil
e</em></a>, and |
| 188 deploy the libraries along with the application. Instructions for how to build | 187 deploy the libraries along with the application. Instructions for how to build |
| 189 a dynamically linked Native Client application, generate a Native Client | 188 a dynamically linked Native Client application, generate a Native Client |
| 190 manifest (.nmf) file, and deploy an application are provided below.</p> | 189 manifest (.nmf) file, and deploy an application are provided below.</p> |
| 191 <h2 id="building-a-dynamically-linked-application">Building a dynamically linked
application</h2> | 190 <h3 id="building-a-dynamically-linked-application">Building a dynamically linked
application</h3> |
| 192 <p>Applications built with the glibc toolchain will by dynamically linked by | 191 <p>Applications built with the glibc toolchain will by dynamically linked by |
| 193 default. Application that load shared libraries at runtime using <code>dlopen()<
/code> | 192 default. Application that load shared libraries at runtime using <code>dlopen()<
/code> |
| 194 must link with the libdl library (<code>-ldl</code>).</p> | 193 must link with the libdl library (<code>-ldl</code>).</p> |
| 195 <p>Like other gcc-based toolchains building a dynamic library for NaCl is normal
ly | 194 <p>Like other gcc-based toolchains building a dynamic library for NaCl is normal
ly |
| 196 done by linking with the <code>-shared</code> flag and compiling with the <code>
-fPIC</code> flag. | 195 done by linking with the <code>-shared</code> flag and compiling with the <code>
-fPIC</code> flag. |
| 197 The SDK build system will do this automatically when the <code>SO_RULE</code> Ma
kefile | 196 The SDK build system will do this automatically when the <code>SO_RULE</code> Ma
kefile |
| 198 rule is used.</p> | 197 rule is used.</p> |
| 199 <p>The Native Client SDK includes an example that demonstrates how to build a | 198 <p>The Native Client SDK includes an example that demonstrates how to build a |
| 200 shared library, and how to use the <code>dlopen()</code> interface to load that
library | 199 shared library, and how to use the <code>dlopen()</code> interface to load that
library |
| 201 at runtime (after the application is already running). Many applications load | 200 at runtime (after the application is already running). Many applications load |
| (...skipping 26 matching lines...) Expand all Loading... |
| 228 <aside class="note"> | 227 <aside class="note"> |
| 229 <strong>Note:</strong> The Makefiles for most of the examples in the SDK build t
he | 228 <strong>Note:</strong> The Makefiles for most of the examples in the SDK build t
he |
| 230 examples using multiple toolchains (x86 newlib, x86 glibc, ARM, and PNaCl). | 229 examples using multiple toolchains (x86 newlib, x86 glibc, ARM, and PNaCl). |
| 231 With a few exceptions (listed in the <a class="reference internal" href="/native
-client/sdk/release-notes.html#sdk-release-notes"><em>Release Notes</em></a>), r
unning “make” in each example’s directory builds | 230 With a few exceptions (listed in the <a class="reference internal" href="/native
-client/sdk/release-notes.html#sdk-release-notes"><em>Release Notes</em></a>), r
unning “make” in each example’s directory builds |
| 232 multiple versions of the example using the SDK toolchains. The dlopen example | 231 multiple versions of the example using the SDK toolchains. The dlopen example |
| 233 is one of those exceptions – it is only built with the x86 glibc toolchain, | 232 is one of those exceptions – it is only built with the x86 glibc toolchain, |
| 234 as that is currently the only toolchain that supports glibc and thus dynamic | 233 as that is currently the only toolchain that supports glibc and thus dynamic |
| 235 linking and loading. Take a look at the example Makefiles and the generated | 234 linking and loading. Take a look at the example Makefiles and the generated |
| 236 .nmf files for details on how to build dynamically linked applications. | 235 .nmf files for details on how to build dynamically linked applications. |
| 237 </aside> | 236 </aside> |
| 238 <h2 id="generating-a-native-client-manifest-file-for-a-dynamically-linked-applic
ation"><span id="dynamic-loading-manifest"></span>Generating a Native Client man
ifest file for a dynamically linked application</h2> | 237 <h3 id="generating-a-native-client-manifest-file-for-a-dynamically-linked-applic
ation"><span id="dynamic-loading-manifest"></span>Generating a Native Client man
ifest file for a dynamically linked application</h3> |
| 239 <p>The Native Client manifest file specifies the name of the executable to run | 238 <p>The Native Client manifest file specifies the name of the executable to run |
| 240 and must also specify any shared libraries that the application directly | 239 and must also specify any shared libraries that the application directly |
| 241 depends on. For indirect dependencies (such as libraries opened via | 240 depends on. For indirect dependencies (such as libraries opened via |
| 242 <code>dlopen()</code>) it is also convenient to list libraries in the manifest f
ile. | 241 <code>dlopen()</code>) it is also convenient to list libraries in the manifest f
ile. |
| 243 However it is possile to load arbitrary shared libraries at runtime that | 242 However it is possile to load arbitrary shared libraries at runtime that |
| 244 are not mentioned in the manifest by using the <a class="reference external" hre
f="nacl_io">nacl_io library</a> | 243 are not mentioned in the manifest by using the <a class="reference external" hre
f="nacl_io">nacl_io library</a> |
| 245 to mount a filesystem that contains the shared libraries which will then | 244 to mount a filesystem that contains the shared libraries which will then |
| 246 allow <code>dlopen()</code> to access them.</p> | 245 allow <code>dlopen()</code> to access them.</p> |
| 247 <p>In this example we demonstrate both loading directly from via the manifest | 246 <p>In this example we demonstrate both loading directly from via the manifest |
| 248 file (<code>libeightball.so</code>) and loading indirectly via a http mount | 247 file (<code>libeightball.so</code>) and loading indirectly via a http mount |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 </dl> | 304 </dl> |
| 306 <aside class="note"> | 305 <aside class="note"> |
| 307 <strong>Note:</strong> The <code>create_nmf</code> script can only automatically
detect explicit | 306 <strong>Note:</strong> The <code>create_nmf</code> script can only automatically
detect explicit |
| 308 shared library dependencies (for example, dependencies specified with the -l | 307 shared library dependencies (for example, dependencies specified with the -l |
| 309 flag for the compiler/linker). If you want to include libraries that you | 308 flag for the compiler/linker). If you want to include libraries that you |
| 310 intend to dlopen() at runtime you must explcitly list them in your call to | 309 intend to dlopen() at runtime you must explcitly list them in your call to |
| 311 <code>create_nmf</code>. | 310 <code>create_nmf</code>. |
| 312 </aside> | 311 </aside> |
| 313 <p>As an alternative to using <code>create_nmf</code>, it is possible to manuall
y calculate | 312 <p>As an alternative to using <code>create_nmf</code>, it is possible to manuall
y calculate |
| 314 the list of shared library dependencies using tools such as <code>objdump_</code
>.</p> | 313 the list of shared library dependencies using tools such as <code>objdump_</code
>.</p> |
| 315 <h2 id="deploying-a-dynamically-linked-application">Deploying a dynamically link
ed application</h2> | 314 <h3 id="deploying-a-dynamically-linked-application">Deploying a dynamically link
ed application</h3> |
| 316 <p>As described above, an application’s manifest file must explicitly list
all the | 315 <p>As described above, an application’s manifest file must explicitly list
all the |
| 317 executable code modules that the application directly depends on, including | 316 executable code modules that the application directly depends on, including |
| 318 modules from the application itself (.nexe and .so files), modules from the | 317 modules from the application itself (.nexe and .so files), modules from the |
| 319 Native Client SDK (e.g., libppapi_cpp.so), and perhaps also modules from | 318 Native Client SDK (e.g., libppapi_cpp.so), and perhaps also modules from |
| 320 <a class="reference external" href="http://code.google.com/p/naclports/">naclpor
ts</a> or from | 319 <a class="reference external" href="http://code.google.com/p/naclports/">naclpor
ts</a> or from |
| 321 <a class="reference external" href="../../community/middleware">middleware syste
ms</a> that | 320 <a class="reference external" href="../../community/middleware">middleware syste
ms</a> that |
| 322 the application uses. You must provide all of those modules as part of the | 321 the application uses. You must provide all of those modules as part of the |
| 323 application deployment process.</p> | 322 application deployment process.</p> |
| 324 <p>As explained in <a class="reference internal" href="/native-client/devguide/d
istributing.html"><em>Distributing Your Application</em></a>, there are two basi
c ways to deploy an application:</p> | 323 <p>As explained in <a class="reference internal" href="/native-client/devguide/d
istributing.html"><em>Distributing Your Application</em></a>, there are two basi
c ways to deploy an application:</p> |
| 325 <ul class="small-gap"> | 324 <ul class="small-gap"> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 336 in the Native Client manifest file, and be named relative to the location of | 335 in the Native Client manifest file, and be named relative to the location of |
| 337 the manifest file. Remember that some of the libraries named in the manifest | 336 the manifest file. Remember that some of the libraries named in the manifest |
| 338 file may be located in directories you specified with the -L option to | 337 file may be located in directories you specified with the -L option to |
| 339 <code>create_nmf.py</code>. You are free to rename/rearrange files and directori
es | 338 <code>create_nmf.py</code>. You are free to rename/rearrange files and directori
es |
| 340 referenced by the Native Client manifest file, so long as the modules are | 339 referenced by the Native Client manifest file, so long as the modules are |
| 341 available in the locations indicated by the manifest file. If you move or | 340 available in the locations indicated by the manifest file. If you move or |
| 342 rename modules, it may be easier to re-run <code>create_nmf.py</code> to generat
e a new | 341 rename modules, it may be easier to re-run <code>create_nmf.py</code> to generat
e a new |
| 343 manifest file rather than edit the original manifest file. For hosted | 342 manifest file rather than edit the original manifest file. For hosted |
| 344 applications, you can check for name mismatches during testing by watching the | 343 applications, you can check for name mismatches during testing by watching the |
| 345 request log of the web server hosting your test deployment.</p> | 344 request log of the web server hosting your test deployment.</p> |
| 346 <h2 id="opening-a-shared-library-at-runtime">Opening a shared library at runtime
</h2> | 345 <h3 id="opening-a-shared-library-at-runtime">Opening a shared library at runtime
</h3> |
| 347 <p>Native Client supports a version of the POSIX standard <code>dlopen()</code>
interface | 346 <p>Native Client supports a version of the POSIX standard <code>dlopen()</code>
interface |
| 348 for opening libraries explicitly, after an application is already running. | 347 for opening libraries explicitly, after an application is already running. |
| 349 Calling <code>dlopen()</code> may cause a library download to occur, and automat
ically | 348 Calling <code>dlopen()</code> may cause a library download to occur, and automat
ically |
| 350 loads all libraries that are required by the named library.</p> | 349 loads all libraries that are required by the named library.</p> |
| 351 <aside class="note"> | 350 <aside class="note"> |
| 352 <strong>Caution:</strong> Since <code>dlopen()</code> can potentially block, you
must initially | 351 <strong>Caution:</strong> Since <code>dlopen()</code> can potentially block, you
must initially |
| 353 call <code>dlopen()</code> off your application’s main thread. Initial cal
ls to | 352 call <code>dlopen()</code> off your application’s main thread. Initial cal
ls to |
| 354 <code>dlopen()</code> from the main thread will always fail in the current | 353 <code>dlopen()</code> from the main thread will always fail in the current |
| 355 implementation of Native Client. | 354 implementation of Native Client. |
| 356 </aside> | 355 </aside> |
| (...skipping 16 matching lines...) Expand all Loading... |
| 373 and makes calls to <code>Magic8Ball()</code> and <code>Reverse()</code> in respo
nse to requests | 372 and makes calls to <code>Magic8Ball()</code> and <code>Reverse()</code> in respo
nse to requests |
| 374 from JavaScript.</li> | 373 from JavaScript.</li> |
| 375 </ul> | 374 </ul> |
| 376 <p>When the Native Client module starts, it kicks off a worker thread that calls | 375 <p>When the Native Client module starts, it kicks off a worker thread that calls |
| 377 <code>dlopen()</code> to load the two shared libraries. Once the module has a ha
ndle to | 376 <code>dlopen()</code> to load the two shared libraries. Once the module has a ha
ndle to |
| 378 the library, it fetches the addresses of the <code>Magic8Ball()</code> and <code
>Reverse()</code> | 377 the library, it fetches the addresses of the <code>Magic8Ball()</code> and <code
>Reverse()</code> |
| 379 functions using <code>dlsym()</code>. When a user types in a query and clicks th
e ‘ASK!’ | 378 functions using <code>dlsym()</code>. When a user types in a query and clicks th
e ‘ASK!’ |
| 380 button, the module calls <code>Magic8Ball()</code> to generate an answer, and re
turns | 379 button, the module calls <code>Magic8Ball()</code> to generate an answer, and re
turns |
| 381 the result to the user. Likewise when the user clicks the ‘Reverse’
button | 380 the result to the user. Likewise when the user clicks the ‘Reverse’
button |
| 382 it calls the <code>Reverse()</code> function to reverse the string.</p> | 381 it calls the <code>Reverse()</code> function to reverse the string.</p> |
| 383 <h2 id="troubleshooting">Troubleshooting</h2> | 382 <h3 id="troubleshooting">Troubleshooting</h3> |
| 384 <p>If your .nexe isn’t loading, the best place to look for information tha
t can | 383 <p>If your .nexe isn’t loading, the best place to look for information tha
t can |
| 385 help you troubleshoot the JavaScript console and standard output from Chrome. | 384 help you troubleshoot the JavaScript console and standard output from Chrome. |
| 386 See <a class="reference internal" href="/native-client/devguide/devcycle/debuggi
ng.html#devcycle-debugging"><em>Debugging</em></a> for more information.</p> | 385 See <a class="reference internal" href="/native-client/devguide/devcycle/debuggi
ng.html#devcycle-debugging"><em>Debugging</em></a> for more information.</p> |
| 387 <p>Here are a few common error messages and explanations of what they mean:</p> | 386 <p>Here are a few common error messages and explanations of what they mean:</p> |
| 388 <dl class="docutils"> | 387 <dl class="docutils"> |
| 389 <dt><strong>/main.nexe: error while loading shared libraries: /main.nexe: failed
to allocate code and data space for executable</strong></dt> | 388 <dt><strong>/main.nexe: error while loading shared libraries: /main.nexe: failed
to allocate code and data space for executable</strong></dt> |
| 390 <dd>The .nexe may not have been compiled correctly (e.g., the .nexe may be | 389 <dd>The .nexe may not have been compiled correctly (e.g., the .nexe may be |
| 391 statically linked). Try cleaning and recompiling with the glibc toolchain.</dd> | 390 statically linked). Try cleaning and recompiling with the glibc toolchain.</dd> |
| 392 <dt><strong>/main.nexe: error while loading shared libraries: libpthread.so.xxxx
: cannot open shared object file: Permission denied</strong></dt> | 391 <dt><strong>/main.nexe: error while loading shared libraries: libpthread.so.xxxx
: cannot open shared object file: Permission denied</strong></dt> |
| 393 <dd>(xxxx is a version number, for example, 5055067a.) This error can result fro
m | 392 <dd>(xxxx is a version number, for example, 5055067a.) This error can result fro
m |
| (...skipping 18 matching lines...) Expand all Loading... |
| 412 in the .nmf file – either the files are the wrong type or kind, or an | 411 in the .nmf file – either the files are the wrong type or kind, or an |
| 413 expected library is missing.</dd> | 412 expected library is missing.</dd> |
| 414 <dt><strong>undefined reference to ‘dlopen’ collect2: ld returned 1
exit status</strong></dt> | 413 <dt><strong>undefined reference to ‘dlopen’ collect2: ld returned 1
exit status</strong></dt> |
| 415 <dd>This is a linker ordering problem that usually results from improper orderin
g | 414 <dd>This is a linker ordering problem that usually results from improper orderin
g |
| 416 of command line flags when linking. Reconfigure your command line string to | 415 of command line flags when linking. Reconfigure your command line string to |
| 417 list libraries after the -o flag.</dd> | 416 list libraries after the -o flag.</dd> |
| 418 </dl> | 417 </dl> |
| 419 </section> | 418 </section> |
| 420 | 419 |
| 421 {{/partials.standard_nacl_article}} | 420 {{/partials.standard_nacl_article}} |
| OLD | NEW |