OLD | NEW |
1 {{+bindTo:partials.standard_nacl_article}} | 1 {{+bindTo:partials.standard_nacl_article}} |
2 | 2 |
3 <section id="running-the-sdk-examples"> | 3 <section id="running-the-sdk-examples"> |
4 <span id="sdk-examples-2"></span><h1 id="running-the-sdk-examples"><span id="sdk
-examples-2"></span>Running the SDK Examples</h1> | 4 <span id="sdk-examples-2"></span><h1 id="running-the-sdk-examples"><span id="sdk
-examples-2"></span>Running the SDK Examples</h1> |
5 <p>Every Native Client SDK bundle comes with a folder of example applications. | 5 <p>Every Native Client SDK bundle comes with a folder of example applications. |
6 Each example demonstrates one or two key Native Client programming concepts. | 6 Each example demonstrates one or two key Native Client programming concepts. |
7 After you’ve <a class="reference internal" href="/native-client/sdk/downlo
ad.html"><em>downloaded the SDK</em></a>, follow the instructions | 7 After you’ve <a class="reference internal" href="/native-client/sdk/downlo
ad.html"><em>downloaded the SDK</em></a>, follow the instructions |
8 on this page to build and run the examples.</p> | 8 on this page to build and run the examples.</p> |
9 <section id="configure-the-google-chrome-browser"> | 9 <p>Your version of Chrome must be equal to or greater than the version of your S
DK |
10 <h2 id="configure-the-google-chrome-browser">Configure the Google Chrome Browser
</h2> | 10 bundle. For example, if you’re developing with the <code>pepper_31</code>
bundle, you |
| 11 must use Google Chrome version 31 or greater. To find out what version of Chrome |
| 12 you’re using, type <code>about:chrome</code> or <code>about:version</code>
in the Chrome address |
| 13 bar.</p> |
| 14 <section id="enable-native-client"> |
| 15 <h2 id="enable-native-client">Enable Native Client</h2> |
| 16 <aside class="note"> |
| 17 If you are using Chrome 31 or later, you can skip this section. |
| 18 </aside> |
| 19 <p>To run Portable Native Client applications you must specifically enable Nativ
e |
| 20 Client in Chrome:</p> |
11 <ol class="arabic"> | 21 <ol class="arabic"> |
12 <li><p class="first">Your version of Chrome must be equal to or greater than the
version of | 22 <li><p class="first">Type <code>about:flags</code> in the Chrome address bar and
scroll down to “Native |
13 your SDK bundle. For example, if you’re developing with the <code>pepper_3
1</code> | 23 Client”.</p> |
14 bundle, you must use Google Chrome version 31 or greater. To find out what | |
15 version of Chrome you’re using, type <code>about:chrome</code> or <code>ab
out:version</code> | |
16 in the Chrome address bar.</p> | |
17 </li> | |
18 <li><p class="first">For Portable Native Client, no extra Chrome flags are neede
d as of | |
19 Chrome version 31.</p> | |
20 <p>For other Native Client applications, or to <strong>debug</strong> Portable N
ative | |
21 Client applications by translating the <strong>pexe</strong> to a <strong>nexe</
strong> ahead of | |
22 time, enable the Native Client flag. Native Client is enabled by default | |
23 only for applications distributed through the Chrome Web Store. To run | |
24 Native Client applications that are not distributed through the Chrome | |
25 Web Store, like the SDK examples, you must specifically enable the Native | |
26 Client flag in Chrome:</p> | |
27 <ul class="small-gap"> | 24 <ul class="small-gap"> |
28 <li><p class="first">Type <code>about:flags</code> in the Chrome address bar and
scroll down to | |
29 “Native Client”.</p> | |
30 </li> | |
31 <li><p class="first">If the link below “Native Client” says “D
isable”, then Native Client is | 25 <li><p class="first">If the link below “Native Client” says “D
isable”, then Native Client is |
32 already enabled and you don’t need to do anything else.</p> | 26 already enabled and you don’t need to do anything else.</p> |
33 </li> | 27 </li> |
| 28 </ul> |
| 29 <ul class="small-gap"> |
34 <li><p class="first">If the link below “Native Client” says “E
nable”, click the “Enable” | 30 <li><p class="first">If the link below “Native Client” says “E
nable”, click the “Enable” |
35 link, scroll down to the bottom of the page, and click the “Relaunch | 31 link.</p> |
36 Now” button. All browser windows will restart when you relaunch Chrome.</p
> | |
37 </li> | 32 </li> |
38 </ul> | 33 </ul> |
39 </li> | 34 </li> |
40 <li><p class="first">Disable the Chrome cache. Chrome caches resources aggressiv
ely; when you | 35 <li><p class="first">Scroll down to the bottom of the page, and click “Rel
aunch Now”. All browser |
41 are building a Native Client application you should disable the cache to | 36 windows will restart when you relaunch Chrome.</p> |
42 make sure that Chrome loads the latest version:</p> | |
43 <ul class="small-gap"> | |
44 <li><p class="first">Open Chrome’s developer tools by clicking the menu ic
on <img alt="menu-icon" src="/native-client/images/menu-icon.png" /> and | |
45 choosing Tools > Developer tools.</p> | |
46 </li> | 37 </li> |
47 <li><p class="first">Click the gear icon <img alt="gear-icon" src="/native-clien
t/images/gear-icon.png" /> in the bottom right corner of the | 38 </ol> |
48 Chrome window.</p> | 39 </section><section id="disable-the-chrome-cache"> |
49 </li> | 40 <h2 id="disable-the-chrome-cache">Disable the Chrome cache</h2> |
50 <li><p class="first">Under the “General” settings, check the box nex
t to “Disable cache”.</p> | 41 <p>Chrome caches resources aggressively. When you are building a Native Client |
51 </li> | 42 application you should disable the cache to make sure that Chrome loads the |
52 </ul> | 43 latest version.</p> |
53 </li> | 44 <ol class="arabic simple"> |
| 45 <li>Open Chrome’s developer tools by clicking the menu icon <img alt="menu
-icon" src="/native-client/images/menu-icon.png" /> and |
| 46 choosing Tools > Developer tools.</li> |
| 47 <li>Click the gear icon <img alt="gear-icon" src="/native-client/images/gear-ico
n.png" /> in the bottom right corner of the Chrome |
| 48 window.</li> |
| 49 <li>Under the “General” settings, check the box next to “Disab
le cache”.</li> |
54 </ol> | 50 </ol> |
55 </section><section id="build-the-sdk-examples"> | 51 </section><section id="build-the-sdk-examples"> |
56 <h2 id="build-the-sdk-examples">Build the SDK examples</h2> | 52 <h2 id="build-the-sdk-examples">Build the SDK examples</h2> |
57 <p>Starting with the <code>pepper_24</code> bundle, the Makefile scripts for the
SDK | 53 <p>The Makefile scripts for the SDK examples build multiple versions of the |
58 examples build multiple versions of the examples using all three SDK | 54 examples using all three SDK toolchains (newlib, glibc, and PNaCl) and in both |
59 toolchains (newlib, glibc, and PNaCl) and in both release and debug | 55 release and debug configurations. (Note that some examples build only with |
60 configurations. (Note that some examples build only with the particular | 56 particular toolchains).</p> |
61 toolchains).</p> | 57 <section id="build-all-examples"> |
| 58 <h3 id="build-all-examples">Build all examples</h3> |
62 <p>To build all the examples, go to the examples directory in a specific SDK | 59 <p>To build all the examples, go to the examples directory in a specific SDK |
63 bundle and run <code>make</code>:</p> | 60 bundle and run <code>make</code>:</p> |
64 <pre class="prettyprint"> | 61 <pre class="prettyprint"> |
65 $ cd pepper_31/examples | 62 $ cd pepper_31/examples |
66 $ make | 63 $ make |
67 make -C api all | 64 make -C api all |
68 make[1]: Entering directory `pepper_31/examples/api' | 65 make[1]: Entering directory `pepper_31/examples/api' |
69 make -C audio all | 66 make -C audio all |
70 make[2]: Entering directory `pepper_31/examples/api/audio' | 67 make[2]: Entering directory `pepper_31/examples/api/audio' |
71 CXX newlib/Debug/audio_x86_32.o | 68 CXX newlib/Debug/audio_x86_32.o |
72 LINK newlib/Debug/audio_x86_32.nexe | 69 LINK newlib/Debug/audio_x86_32.nexe |
73 CXX newlib/Debug/audio_x86_64.o | 70 CXX newlib/Debug/audio_x86_64.o |
74 LINK newlib/Debug/audio_x86_64.nexe | 71 LINK newlib/Debug/audio_x86_64.nexe |
75 CXX newlib/Debug/audio_arm.o | 72 CXX newlib/Debug/audio_arm.o |
76 LINK newlib/Debug/audio_arm.nexe | 73 LINK newlib/Debug/audio_arm.nexe |
77 CREATE_NMF newlib/Debug/audio.nmf | 74 CREATE_NMF newlib/Debug/audio.nmf |
78 make[2]: Leaving directory `pepper_31/examples/api/audio' | 75 make[2]: Leaving directory `pepper_31/examples/api/audio' |
79 make -C url_loader all | 76 make -C url_loader all |
80 make[2]: Entering directory `pepper_31/examples/api/url_loader' | 77 make[2]: Entering directory `pepper_31/examples/api/url_loader' |
81 CXX newlib/Debug/url_loader_x86_32.o | 78 CXX newlib/Debug/url_loader_x86_32.o |
82 ... | 79 ... |
83 </pre> | 80 </pre> |
| 81 </section><section id="build-a-single-example"> |
| 82 <h3 id="build-a-single-example">Build a single example</h3> |
84 <p>Calling <code>make</code> from inside a particular example’s directory
will build only | 83 <p>Calling <code>make</code> from inside a particular example’s directory
will build only |
85 that example:</p> | 84 that example:</p> |
86 <pre class="prettyprint"> | 85 <pre class="prettyprint"> |
87 $ cd pepper_31/examples/api/core | 86 $ cd pepper_31/examples/api/core |
88 $ make | 87 $ make |
89 CXX newlib/Debug/core_x86_32.o | 88 CXX newlib/Debug/core_x86_32.o |
90 LINK newlib/Debug/core_x86_32.nexe | 89 LINK newlib/Debug/core_x86_32.nexe |
91 CXX newlib/Debug/core_x86_64.o | 90 CXX newlib/Debug/core_x86_64.o |
92 LINK newlib/Debug/core_x86_64.nexe | 91 LINK newlib/Debug/core_x86_64.nexe |
93 CXX newlib/Debug/core_arm.o | 92 CXX newlib/Debug/core_arm.o |
94 LINK newlib/Debug/core_arm.nexe | 93 LINK newlib/Debug/core_arm.nexe |
95 CREATE_NMF newlib/Debug/core.nmf | 94 CREATE_NMF newlib/Debug/core.nmf |
96 </pre> | 95 </pre> |
| 96 </section><section id="override-defaults"> |
| 97 <h3 id="override-defaults">Override defaults</h3> |
97 <p>You can call <code>make</code> with the <code>TOOLCHAIN</code> and <code>CONF
IG</code> parameters to | 98 <p>You can call <code>make</code> with the <code>TOOLCHAIN</code> and <code>CONF
IG</code> parameters to |
98 override the defaults:</p> | 99 override the defaults:</p> |
99 <pre class="prettyprint"> | 100 <pre class="prettyprint"> |
100 $ make TOOLCHAIN=pnacl CONFIG=Release | 101 $ make TOOLCHAIN=pnacl CONFIG=Release |
101 CXX pnacl/Release/core_pnacl.o | 102 CXX pnacl/Release/core_pnacl.o |
102 LINK pnacl/Release/core.bc | 103 LINK pnacl/Release/core.bc |
103 FINALIZE pnacl/Release/core.pexe | 104 FINALIZE pnacl/Release/core.pexe |
104 CREATE_NMF pnacl/Release/core.nmf | 105 CREATE_NMF pnacl/Release/core.nmf |
105 </pre> | 106 </pre> |
106 <p>You can also set <code>TOOLCHAIN</code> to “all” to build one or
more examples with | 107 <p>You can also set <code>TOOLCHAIN</code> to “all” to build one or
more examples with |
(...skipping 24 matching lines...) Expand all Loading... |
131 LINK pnacl/Debug/core_unstripped.bc | 132 LINK pnacl/Debug/core_unstripped.bc |
132 FINALIZE pnacl/Debug/core_unstripped.pexe | 133 FINALIZE pnacl/Debug/core_unstripped.pexe |
133 CREATE_NMF pnacl/Debug/core.nmf | 134 CREATE_NMF pnacl/Debug/core.nmf |
134 make[1]: Leaving directory `pepper_31/examples/api/core' | 135 make[1]: Leaving directory `pepper_31/examples/api/core' |
135 make TOOLCHAIN=linux | 136 make TOOLCHAIN=linux |
136 make[1]: Entering directory `pepper_31/examples/api/core' | 137 make[1]: Entering directory `pepper_31/examples/api/core' |
137 CXX linux/Debug/core.o | 138 CXX linux/Debug/core.o |
138 LINK linux/Debug/core.so | 139 LINK linux/Debug/core.so |
139 make[1]: Leaving directory `pepper_31/examples/api/core' | 140 make[1]: Leaving directory `pepper_31/examples/api/core' |
140 </pre> | 141 </pre> |
| 142 </section></section><section id="build-results"> |
| 143 <h2 id="build-results">Build results</h2> |
141 <p>After running <code>make</code>, each example directory will contain one or m
ore of | 144 <p>After running <code>make</code>, each example directory will contain one or m
ore of |
142 the following subdirectories:</p> | 145 the following subdirectories:</p> |
143 <ul class="small-gap"> | 146 <ul class="small-gap"> |
144 <li>a <code>newlib</code> directory with subdirectories <code>Debug</code> and <
code>Release</code>;</li> | 147 <li><code>newlib</code> with subdirectories <code>Debug</code> and <code>Release
</code>;</li> |
145 <li>a <code>glibc</code> directory with subdirectories <code>Debug</code> and <c
ode>Release</code>;</li> | 148 <li><code>glibc</code> with subdirectories <code>Debug</code> and <code>Release<
/code>;</li> |
146 <li>a <code>pnacl</code> directory with subdirectories <code>Debug</code> and <c
ode>Release</code>;</li> | 149 <li><code>pnacl</code> with subdirectories <code>Debug</code> and <code>Release<
/code>;</li> |
147 </ul> | 150 </ul> |
148 <p>For the newlib and glibc toolchains the Debug and Release subdirectories | 151 <p>For the newlib and glibc toolchains the Debug and Release subdirectories |
149 contain .nexe files for all target architectures. For the PNaCl toolchain | 152 contain .nexe files for all target architectures. For the PNaCl toolchain |
150 they contain a single .pexe file. PNaCl debug also produces pre-translated | 153 they contain a single .pexe file. PNaCl debug also produces pre-translated |
151 .nexe files, for ease of debugging. All Debug and Release directories contain | 154 .nexe files, for ease of debugging. All Debug and Release directories contain |
152 a manifest (.nmf) file that references the associated .nexe or .pexe files. | 155 a manifest (.nmf) file that references the associated .nexe or .pexe files. |
153 For information about Native Client manifest files, see the <a class="reference
internal" href="/native-client/overview.html"><em>Technical | 156 For information about Native Client manifest files, see the <a class="reference
internal" href="/native-client/overview.html"><em>Technical |
154 Overview</em></a>.</p> | 157 Overview</em></a>.</p> |
155 <p>For details on how to use <code>make</code>, see the <a class="reference exte
rnal" href="http://www.gnu.org/software/make/manual/make.html">GNU ‘make&#
8217; Manual</a>. For details on how to | 158 <p>For details on how to use <code>make</code>, see the <a class="reference exte
rnal" href="http://www.gnu.org/software/make/manual/make.html">GNU ‘make&#
8217; Manual</a>. For details on how to |
156 use the SDK toolchain itself, see <a class="reference internal" href="/native-cl
ient/devguide/devcycle/building.html"><em>Building Native Client Modules</em></a
>.</p> | 159 use the SDK toolchain itself, see <a class="reference internal" href="/native-cl
ient/devguide/devcycle/building.html"><em>Building Native Client Modules</em></a
>.</p> |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 Remote debugging using :4014 | 245 Remote debugging using :4014 |
243 0x000000000fa00080 in ?? () | 246 0x000000000fa00080 in ?? () |
244 </pre> | 247 </pre> |
245 <p>At this point, you can use the standard GDB commands to debug your NaCl modul
e. | 248 <p>At this point, you can use the standard GDB commands to debug your NaCl modul
e. |
246 The most common commands you will use to debug are <code>continue</code>, <code>
step</code>, | 249 The most common commands you will use to debug are <code>continue</code>, <code>
step</code>, |
247 <code>next</code>, <code>break</code> and <code>backtrace</code>. See <a class="
reference internal" href="/native-client/devguide/devcycle/debugging.html"><em>D
ebugging</em></a> for more information about debugging a Native Client | 250 <code>next</code>, <code>break</code> and <code>backtrace</code>. See <a class="
reference internal" href="/native-client/devguide/devcycle/debugging.html"><em>D
ebugging</em></a> for more information about debugging a Native Client |
248 application.</p> | 251 application.</p> |
249 </section></section> | 252 </section></section> |
250 | 253 |
251 {{/partials.standard_nacl_article}} | 254 {{/partials.standard_nacl_article}} |
OLD | NEW |