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