OLD | NEW |
1 {{+bindTo:partials.standard_nacl_article}} | 1 {{+bindTo:partials.standard_nacl_article}} |
2 | 2 |
3 <span class="target" id="sdk-examples-2"></span><section id="examples"> | 3 <span class="target" id="sdk-examples-2"></span><section id="examples"> |
4 <h1 id="examples">Examples</h1> | 4 <h1 id="examples">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 <p>Your version of Chrome must be equal to or greater than the version of your S
DK | 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_35</code>
bundle, you | 10 bundle. For example, if you’re developing with the <code>pepper_35</code>
bundle, you |
11 must use Google Chrome version 35 or greater. To find out what version of Chrome | 11 must use Google Chrome version 35 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 | 12 you’re using, type <code>about:chrome</code> or <code>about:version</code>
in the Chrome address |
13 bar.</p> | 13 bar.</p> |
14 <h2 id="build-the-sdk-examples"><span id="id1"></span>Build the SDK examples</h2
> | 14 <h2 id="build-the-sdk-examples"><span id="id1"></span>Build the SDK examples</h2
> |
15 <p>The Makefile scripts for the SDK examples can build multiple versions of the | 15 <p>The Makefile scripts for the SDK examples can build multiple versions of the |
16 examples using any of the three SDK toolchains (newlib, glibc, and PNaCl) and in | 16 examples using any of the three SDK toolchains (clang-newlib, glibc, and PNaCl) |
17 both release and debug configurations. Note that some examples, <code>dlopen</co
de> for | 17 and in both release and debug configurations. Note that some examples, |
18 example, build only with particular toolchains.</p> | 18 <code>dlopen</code> for example, build only with particular toolchains.</p> |
19 <p>Find the toolchains for each example by looking at the <code>VALID_TOOLCHAINS
</code> | 19 <p>Find the toolchains for each example by looking at the <code>VALID_TOOLCHAINS
</code> |
20 variable in the Makefile for a particular example. The first item listed is the | 20 variable in the Makefile for a particular example. The first item listed is the |
21 default. It’s built when you run an example make file without parameters.
for | 21 default. It’s built when you run an example make file without parameters.
for |
22 example running make in the <code>core</code> directory of pepper_35 builds the
example | 22 example running make in the <code>core</code> directory of pepper_35 builds the
example |
23 using the <code>newlib</code> toolchain.</p> | 23 using the <code>glibc</code> toolchain.</p> |
24 <pre class="prettyprint"> | 24 <pre class="prettyprint"> |
25 $ cd pepper_35/examples/api/core | 25 $ cd pepper_35/examples/api/core |
26 $ make | 26 $ make |
27 CXX newlib/Release/core_x86_32.o | 27 CXX glibc/Release/core_x86_32.o |
28 LINK newlib/Release/core_unstripped_x86_32.nexe | 28 LINK glibc/Release/core_unstripped_x86_32.nexe |
29 VALIDATE newlib/Release/core_unstripped_x86_32.nexe | 29 VALIDATE glibc/Release/core_unstripped_x86_32.nexe |
30 CXX newlib/Release/core_x86_64.o | 30 CXX glibc/Release/core_x86_64.o |
31 LINK newlib/Release/core_unstripped_x86_64.nexe | 31 LINK glibc/Release/core_unstripped_x86_64.nexe |
32 VALIDATE newlib/Release/core_unstripped_x86_64.nexe | 32 VALIDATE glibc/Release/core_unstripped_x86_64.nexe |
33 CXX newlib/Release/core_arm.o | 33 CXX glibc/Release/core_arm.o |
34 LINK newlib/Release/core_unstripped_arm.nexe | 34 LINK glibc/Release/core_unstripped_arm.nexe |
35 VALIDATE newlib/Release/core_unstripped_arm.nexe | 35 VALIDATE glibc/Release/core_unstripped_arm.nexe |
36 STRIP newlib/Release/core_x86_32.nexe | 36 STRIP glibc/Release/core_x86_32.nexe |
37 STRIP newlib/Release/core_x86_64.nexe | 37 STRIP glibc/Release/core_x86_64.nexe |
38 STRIP newlib/Release/core_arm.nexe | 38 STRIP glibc/Release/core_arm.nexe |
39 CREATE_NMF newlib/Release/core.nmf | 39 CREATE_NMF glibc/Release/core.nmf |
40 </pre> | 40 </pre> |
41 <p>As you can see, this produces a number of architecture specific nexe files in | 41 <p>As you can see, this produces a number of architecture specific nexe files in |
42 the <code>pepper_35/examples/api/core/Release</code> directory. Create debug ve
rsions by | 42 the <code>pepper_35/examples/api/core/Release</code> directory. Create debug ve
rsions by |
43 using the <code>CONFIG</code> parameter of the make command.</p> | 43 using the <code>CONFIG</code> parameter of the make command.</p> |
44 <pre class="prettyprint"> | 44 <pre class="prettyprint"> |
45 $make CONFIG=Debug | 45 $make CONFIG=Debug |
46 </pre> | 46 </pre> |
47 <p>This creates similar output, but in <code>pepper_35/examples/api/core/Debug</
code>.</p> | 47 <p>This creates similar output, but in <code>pepper_35/examples/api/core/Debug</
code>.</p> |
48 <p>Select a different toolchain with the <code>TOOLCHAIN</code> parameter. For
example:</p> | 48 <p>Select a different toolchain with the <code>TOOLCHAIN</code> parameter. For
example:</p> |
49 <pre class="prettyprint"> | 49 <pre class="prettyprint"> |
50 $ cd pepper_35/examples/api/core | 50 $ cd pepper_35/examples/api/core |
51 $ make TOOLCHAIN=pnacl CONFIG=Release | 51 $ make TOOLCHAIN=pnacl CONFIG=Release |
52 CXX pnacl/Release/core.o | 52 CXX pnacl/Release/core.o |
53 LINK pnacl/Release/core_unstripped.bc | 53 LINK pnacl/Release/core_unstripped.bc |
54 FINALIZE pnacl/Release/core_unstripped.pexe | 54 FINALIZE pnacl/Release/core_unstripped.pexe |
55 CREATE_NMF pnacl/Release/core.nmf | 55 CREATE_NMF pnacl/Release/core.nmf |
56 </pre> | 56 </pre> |
57 <p>You can also set <code>TOOLCHAIN</code> to <code>all</code> to build all Rele
ase versions with | 57 <p>You can also set <code>TOOLCHAIN</code> to <code>all</code> to build all Rele
ase versions with |
58 default toolchains.</p> | 58 default toolchains.</p> |
59 <pre class="prettyprint"> | 59 <pre class="prettyprint"> |
60 $ cd pepper_35/examples/api/core | 60 $ cd pepper_35/examples/api/core |
61 $ make TOOLCHAIN=all | 61 $ make TOOLCHAIN=all |
62 make TOOLCHAIN=newlib | 62 make TOOLCHAIN=clang-newlib |
63 make[1]: Entering directory 'pepper_35/examples/api/core' | 63 make[1]: Entering directory 'pepper_35/examples/api/core' |
64 CXX newlib/Release/core_x86_32.o | 64 CXX clang-newlib/Release/core_x86_32.o |
65 LINK newlib/Release/core_unstripped_x86_32.nexe | 65 LINK clang-newlib/Release/core_unstripped_x86_32.nexe |
66 VALIDATE newlib/Release/core_unstripped_x86_32.nexe | 66 VALIDATE clang-newlib/Release/core_unstripped_x86_32.nexe |
67 CXX newlib/Release/core_x86_64.o | 67 CXX clang-newlib/Release/core_x86_64.o |
68 LINK newlib/Release/core_unstripped_x86_64.nexe | 68 LINK clang-newlib/Release/core_unstripped_x86_64.nexe |
69 VALIDATE newlib/Release/core_unstripped_x86_64.nexe | 69 VALIDATE clang-newlib/Release/core_unstripped_x86_64.nexe |
70 CXX newlib/Release/core_arm.o | 70 CXX clang-newlib/Release/core_arm.o |
71 LINK newlib/Release/core_unstripped_arm.nexe | 71 LINK clang-newlib/Release/core_unstripped_arm.nexe |
72 VALIDATE newlib/Release/core_unstripped_arm.nexe | 72 VALIDATE clang-newlib/Release/core_unstripped_arm.nexe |
73 STRIP newlib/Release/core_x86_32.nexe | 73 STRIP clang-newlib/Release/core_x86_32.nexe |
74 STRIP newlib/Release/core_x86_64.nexe | 74 STRIP clang-newlib/Release/core_x86_64.nexe |
75 STRIP newlib/Release/core_arm.nexe | 75 STRIP clang-newlib/Release/core_arm.nexe |
76 CREATE_NMF newlib/Release/core.nmf | 76 CREATE_NMF clang-newlib/Release/core.nmf |
77 make[1]: Leaving directory 'pepper_35/examples/api/core' | 77 make[1]: Leaving directory 'pepper_35/examples/api/core' |
78 make TOOLCHAIN=glibc | 78 make TOOLCHAIN=glibc |
79 make[1]: Entering directory 'pepper_35/examples/api/core' | 79 make[1]: Entering directory 'pepper_35/examples/api/core' |
80 CXX glibc/Release/core_x86_32.o | 80 CXX glibc/Release/core_x86_32.o |
81 LINK glibc/Release/core_unstripped_x86_32.nexe | 81 LINK glibc/Release/core_unstripped_x86_32.nexe |
82 VALIDATE glibc/Release/core_unstripped_x86_32.nexe | 82 VALIDATE glibc/Release/core_unstripped_x86_32.nexe |
83 CXX glibc/Release/core_x86_64.o | 83 CXX glibc/Release/core_x86_64.o |
84 LINK glibc/Release/core_unstripped_x86_64.nexe | 84 LINK glibc/Release/core_unstripped_x86_64.nexe |
85 VALIDATE glibc/Release/core_unstripped_x86_64.nexe | 85 VALIDATE glibc/Release/core_unstripped_x86_64.nexe |
86 ... | 86 ... |
87 (content excerpted) | 87 (content excerpted) |
88 ... | 88 ... |
89 </pre> | 89 </pre> |
90 <h3 id="build-results"><span id="id2"></span>Build results</h3> | 90 <h3 id="build-results"><span id="id2"></span>Build results</h3> |
91 <p>After running <code>make</code>, example directories will contain one or more
of the | 91 <p>After running <code>make</code>, example directories will contain one or more
of the |
92 following subdirectories, depending on which Makefile you run:</p> | 92 following subdirectories, depending on which Makefile you run:</p> |
93 <ul class="small-gap"> | 93 <ul class="small-gap"> |
94 <li><code>newlib</code> with subdirectories <code>Debug</code> and <code>Release
</code>;</li> | 94 <li><code>clang-newlib</code> with subdirectories <code>Debug</code> and <code>R
elease</code>;</li> |
95 <li><code>glibc</code> with subdirectories <code>Debug</code> and <code>Release<
/code>;</li> | 95 <li><code>glibc</code> with subdirectories <code>Debug</code> and <code>Release<
/code>;</li> |
96 <li><code>pnacl</code> with subdirectories <code>Debug</code> and <code>Release<
/code>;</li> | 96 <li><code>pnacl</code> with subdirectories <code>Debug</code> and <code>Release<
/code>;</li> |
97 </ul> | 97 </ul> |
98 <p>For the newlib and glibc toolchains the Debug and Release subdirectories | 98 <p>For the clang-newlib and glibc toolchains the Debug and Release subdirectorie
s |
99 contain .nexe files for all target architectures. For the PNaCl toolchain | 99 contain .nexe files for all target architectures. For the PNaCl toolchain |
100 they contain a single .pexe file. PNaCl debug also produces pre-translated | 100 they contain a single .pexe file. PNaCl debug also produces pre-translated |
101 .nexe files, for ease of debugging. All Debug and Release directories contain | 101 .nexe files, for ease of debugging. All Debug and Release directories contain |
102 a manifest (.nmf) file that references the associated .nexe or .pexe files. | 102 a manifest (.nmf) file that references the associated .nexe or .pexe files. |
103 For information about Native Client manifest files, see the <a class="reference
internal" href="/native-client/overview.html"><em>Technical | 103 For information about Native Client manifest files, see the <a class="reference
internal" href="/native-client/overview.html"><em>Technical |
104 Overview</em></a>.</p> | 104 Overview</em></a>.</p> |
105 <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 | 105 <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 |
106 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> | 106 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> |
107 <h2 id="run-the-sdk-examples"><span id="running-the-sdk-examples"></span>Run the
SDK examples</h2> | 107 <h2 id="run-the-sdk-examples"><span id="running-the-sdk-examples"></span>Run the
SDK examples</h2> |
108 <h3 id="disable-the-chrome-cache"><span id="disable-chrome-cache"></span>Disable
the Chrome cache</h3> | 108 <h3 id="disable-the-chrome-cache"><span id="disable-chrome-cache"></span>Disable
the Chrome cache</h3> |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 0x000000000fa00080 in ?? () | 200 0x000000000fa00080 in ?? () |
201 </pre> | 201 </pre> |
202 <p>At this point, you can use the standard GDB commands to debug your NaCl modul
e. | 202 <p>At this point, you can use the standard GDB commands to debug your NaCl modul
e. |
203 The most common commands you will use to debug are <code>continue</code>, <code>
step</code>, | 203 The most common commands you will use to debug are <code>continue</code>, <code>
step</code>, |
204 <code>next</code>, <code>break</code> and <code>backtrace</code>. See | 204 <code>next</code>, <code>break</code> and <code>backtrace</code>. See |
205 <a class="reference internal" href="/native-client/devguide/devcycle/debugging.h
tml"><em>Debugging</em></a> for more information about | 205 <a class="reference internal" href="/native-client/devguide/devcycle/debugging.h
tml"><em>Debugging</em></a> for more information about |
206 debugging a Native Client application.</p> | 206 debugging a Native Client application.</p> |
207 </section> | 207 </section> |
208 | 208 |
209 {{/partials.standard_nacl_article}} | 209 {{/partials.standard_nacl_article}} |
OLD | NEW |