OLD | NEW |
1 .. _sdk-examples-2: | 1 .. _sdk-examples-2: |
2 | 2 |
3 Running the SDK Examples | 3 Running the SDK Examples |
4 ======================== | 4 ======================== |
5 | 5 |
6 Every Native Client SDK bundle comes with a folder of example applications. | 6 Every Native Client SDK bundle comes with a folder of example applications. |
7 Each example demonstrates one or two key Native Client programming concepts. | 7 Each example demonstrates one or two key Native Client programming concepts. |
8 After you've :doc:`downloaded the SDK <download>`, follow the instructions | 8 After you've :doc:`downloaded the SDK <download>`, follow the instructions |
9 on this page to build and run the examples. | 9 on this page to build and run the examples. |
10 | 10 |
11 Configure the Google Chrome Browser | 11 Your version of Chrome must be equal to or greater than the version of your SDK |
12 ----------------------------------- | 12 bundle. For example, if you're developing with the ``pepper_31`` bundle, you |
| 13 must use Google Chrome version 31 or greater. To find out what version of Chrome |
| 14 you're using, type ``about:chrome`` or ``about:version`` in the Chrome address |
| 15 bar. |
13 | 16 |
14 #. Your version of Chrome must be equal to or greater than the version of | 17 |
15 your SDK bundle. For example, if you're developing with the ``pepper_31`` | 18 Enable Native Client |
16 bundle, you must use Google Chrome version 31 or greater. To find out what | 19 -------------------- |
17 version of Chrome you're using, type ``about:chrome`` or ``about:version`` | |
18 in the Chrome address bar. | |
19 | 20 |
20 #. For Portable Native Client, no extra Chrome flags are needed as of | 21 .. note:: |
21 Chrome version 31. | 22 :class: note |
| 23 |
| 24 If you are using Chrome 31 or later, you can skip this section. |
22 | 25 |
23 For other Native Client applications, or to **debug** Portable Native | 26 To run Portable Native Client applications you must specifically enable Native |
24 Client applications by translating the **pexe** to a **nexe** ahead of | 27 Client in Chrome: |
25 time, enable the Native Client flag. Native Client is enabled by default | |
26 only for applications distributed through the Chrome Web Store. To run | |
27 Native Client applications that are not distributed through the Chrome | |
28 Web Store, like the SDK examples, you must specifically enable the Native | |
29 Client flag in Chrome: | |
30 | 28 |
31 * Type ``about:flags`` in the Chrome address bar and scroll down to | 29 #. Type ``about:flags`` in the Chrome address bar and scroll down to "Native |
32 "Native Client". | 30 Client". |
33 * If the link below "Native Client" says "Disable", then Native Client is | 31 |
| 32 - If the link below "Native Client" says "Disable", then Native Client is |
34 already enabled and you don't need to do anything else. | 33 already enabled and you don't need to do anything else. |
| 34 |
35 * If the link below "Native Client" says "Enable", click the "Enable" | 35 * If the link below "Native Client" says "Enable", click the "Enable" |
36 link, scroll down to the bottom of the page, and click the "Relaunch | 36 link. |
37 Now" button. All browser windows will restart when you relaunch Chrome. | 37 |
| 38 #. Scroll down to the bottom of the page, and click "Relaunch Now". All browser |
| 39 windows will restart when you relaunch Chrome. |
38 | 40 |
39 #. Disable the Chrome cache. Chrome caches resources aggressively; when you | 41 Disable the Chrome cache |
40 are building a Native Client application you should disable the cache to | 42 ------------------------ |
41 make sure that Chrome loads the latest version: | |
42 | 43 |
43 * Open Chrome's developer tools by clicking the menu icon |menu-icon| and | 44 Chrome caches resources aggressively. When you are building a Native Client |
44 choosing Tools > Developer tools. | 45 application you should disable the cache to make sure that Chrome loads the |
45 * Click the gear icon |gear-icon| in the bottom right corner of the | 46 latest version. |
46 Chrome window. | 47 |
47 * Under the "General" settings, check the box next to "Disable cache". | 48 #. Open Chrome's developer tools by clicking the menu icon |menu-icon| and |
| 49 choosing Tools > Developer tools. |
| 50 |
| 51 #. Click the gear icon |gear-icon| in the bottom right corner of the Chrome |
| 52 window. |
| 53 |
| 54 #. Under the "General" settings, check the box next to "Disable cache". |
48 | 55 |
49 Build the SDK examples | 56 Build the SDK examples |
50 ---------------------- | 57 ---------------------- |
51 | 58 |
52 Starting with the ``pepper_24`` bundle, the Makefile scripts for the SDK | 59 The Makefile scripts for the SDK examples build multiple versions of the |
53 examples build multiple versions of the examples using all three SDK | 60 examples using all three SDK toolchains (newlib, glibc, and PNaCl) and in both |
54 toolchains (newlib, glibc, and PNaCl) and in both release and debug | 61 release and debug configurations. (Note that some examples build only with |
55 configurations. (Note that some examples build only with the particular | 62 particular toolchains). |
56 toolchains). | 63 |
| 64 Build all examples |
| 65 ^^^^^^^^^^^^^^^^^^ |
57 | 66 |
58 To build all the examples, go to the examples directory in a specific SDK | 67 To build all the examples, go to the examples directory in a specific SDK |
59 bundle and run ``make``:: | 68 bundle and run ``make``:: |
60 | 69 |
61 $ cd pepper_31/examples | 70 $ cd pepper_31/examples |
62 $ make | 71 $ make |
63 make -C api all | 72 make -C api all |
64 make[1]: Entering directory `pepper_31/examples/api' | 73 make[1]: Entering directory `pepper_31/examples/api' |
65 make -C audio all | 74 make -C audio all |
66 make[2]: Entering directory `pepper_31/examples/api/audio' | 75 make[2]: Entering directory `pepper_31/examples/api/audio' |
67 CXX newlib/Debug/audio_x86_32.o | 76 CXX newlib/Debug/audio_x86_32.o |
68 LINK newlib/Debug/audio_x86_32.nexe | 77 LINK newlib/Debug/audio_x86_32.nexe |
69 CXX newlib/Debug/audio_x86_64.o | 78 CXX newlib/Debug/audio_x86_64.o |
70 LINK newlib/Debug/audio_x86_64.nexe | 79 LINK newlib/Debug/audio_x86_64.nexe |
71 CXX newlib/Debug/audio_arm.o | 80 CXX newlib/Debug/audio_arm.o |
72 LINK newlib/Debug/audio_arm.nexe | 81 LINK newlib/Debug/audio_arm.nexe |
73 CREATE_NMF newlib/Debug/audio.nmf | 82 CREATE_NMF newlib/Debug/audio.nmf |
74 make[2]: Leaving directory `pepper_31/examples/api/audio' | 83 make[2]: Leaving directory `pepper_31/examples/api/audio' |
75 make -C url_loader all | 84 make -C url_loader all |
76 make[2]: Entering directory `pepper_31/examples/api/url_loader' | 85 make[2]: Entering directory `pepper_31/examples/api/url_loader' |
77 CXX newlib/Debug/url_loader_x86_32.o | 86 CXX newlib/Debug/url_loader_x86_32.o |
78 ... | 87 ... |
| 88 |
| 89 Build a single example |
| 90 ^^^^^^^^^^^^^^^^^^^^^^ |
79 | 91 |
80 Calling ``make`` from inside a particular example's directory will build only | 92 Calling ``make`` from inside a particular example's directory will build only |
81 that example:: | 93 that example:: |
82 | 94 |
83 $ cd pepper_31/examples/api/core | 95 $ cd pepper_31/examples/api/core |
84 $ make | 96 $ make |
85 CXX newlib/Debug/core_x86_32.o | 97 CXX newlib/Debug/core_x86_32.o |
86 LINK newlib/Debug/core_x86_32.nexe | 98 LINK newlib/Debug/core_x86_32.nexe |
87 CXX newlib/Debug/core_x86_64.o | 99 CXX newlib/Debug/core_x86_64.o |
88 LINK newlib/Debug/core_x86_64.nexe | 100 LINK newlib/Debug/core_x86_64.nexe |
89 CXX newlib/Debug/core_arm.o | 101 CXX newlib/Debug/core_arm.o |
90 LINK newlib/Debug/core_arm.nexe | 102 LINK newlib/Debug/core_arm.nexe |
91 CREATE_NMF newlib/Debug/core.nmf | 103 CREATE_NMF newlib/Debug/core.nmf |
92 | 104 |
| 105 Override defaults |
| 106 ^^^^^^^^^^^^^^^^^ |
| 107 |
93 You can call ``make`` with the ``TOOLCHAIN`` and ``CONFIG`` parameters to | 108 You can call ``make`` with the ``TOOLCHAIN`` and ``CONFIG`` parameters to |
94 override the defaults:: | 109 override the defaults:: |
95 | 110 |
96 $ make TOOLCHAIN=pnacl CONFIG=Release | 111 $ make TOOLCHAIN=pnacl CONFIG=Release |
97 CXX pnacl/Release/core_pnacl.o | 112 CXX pnacl/Release/core_pnacl.o |
98 LINK pnacl/Release/core.bc | 113 LINK pnacl/Release/core.bc |
99 FINALIZE pnacl/Release/core.pexe | 114 FINALIZE pnacl/Release/core.pexe |
100 CREATE_NMF pnacl/Release/core.nmf | 115 CREATE_NMF pnacl/Release/core.nmf |
101 | 116 |
102 | 117 |
(...skipping 25 matching lines...) Expand all Loading... |
128 LINK pnacl/Debug/core_unstripped.bc | 143 LINK pnacl/Debug/core_unstripped.bc |
129 FINALIZE pnacl/Debug/core_unstripped.pexe | 144 FINALIZE pnacl/Debug/core_unstripped.pexe |
130 CREATE_NMF pnacl/Debug/core.nmf | 145 CREATE_NMF pnacl/Debug/core.nmf |
131 make[1]: Leaving directory `pepper_31/examples/api/core' | 146 make[1]: Leaving directory `pepper_31/examples/api/core' |
132 make TOOLCHAIN=linux | 147 make TOOLCHAIN=linux |
133 make[1]: Entering directory `pepper_31/examples/api/core' | 148 make[1]: Entering directory `pepper_31/examples/api/core' |
134 CXX linux/Debug/core.o | 149 CXX linux/Debug/core.o |
135 LINK linux/Debug/core.so | 150 LINK linux/Debug/core.so |
136 make[1]: Leaving directory `pepper_31/examples/api/core' | 151 make[1]: Leaving directory `pepper_31/examples/api/core' |
137 | 152 |
| 153 Build results |
| 154 ------------- |
138 | 155 |
139 After running ``make``, each example directory will contain one or more of | 156 After running ``make``, each example directory will contain one or more of |
140 the following subdirectories: | 157 the following subdirectories: |
141 | 158 |
142 * a ``newlib`` directory with subdirectories ``Debug`` and ``Release``; | 159 * ``newlib`` with subdirectories ``Debug`` and ``Release``; |
143 * a ``glibc`` directory with subdirectories ``Debug`` and ``Release``; | 160 * ``glibc`` with subdirectories ``Debug`` and ``Release``; |
144 * a ``pnacl`` directory with subdirectories ``Debug`` and ``Release``; | 161 * ``pnacl`` with subdirectories ``Debug`` and ``Release``; |
145 | 162 |
146 For the newlib and glibc toolchains the Debug and Release subdirectories | 163 For the newlib and glibc toolchains the Debug and Release subdirectories |
147 contain .nexe files for all target architectures. For the PNaCl toolchain | 164 contain .nexe files for all target architectures. For the PNaCl toolchain |
148 they contain a single .pexe file. PNaCl debug also produces pre-translated | 165 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 | 166 .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. | 167 a manifest (.nmf) file that references the associated .nexe or .pexe files. |
151 For information about Native Client manifest files, see the :doc:`Technical | 168 For information about Native Client manifest files, see the :doc:`Technical |
152 Overview <../overview>`. | 169 Overview <../overview>`. |
153 | 170 |
154 For details on how to use ``make``, see the `GNU 'make' Manual | 171 For details on how to use ``make``, see the `GNU 'make' Manual |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 | 275 |
259 At this point, you can use the standard GDB commands to debug your NaCl module. | 276 At this point, you can use the standard GDB commands to debug your NaCl module. |
260 The most common commands you will use to debug are ``continue``, ``step``, | 277 The most common commands you will use to debug are ``continue``, ``step``, |
261 ``next``, ``break`` and ``backtrace``. See :doc:`Debugging | 278 ``next``, ``break`` and ``backtrace``. See :doc:`Debugging |
262 <../devguide/devcycle/debugging>` for more information about debugging a Native
Client | 279 <../devguide/devcycle/debugging>` for more information about debugging a Native
Client |
263 application. | 280 application. |
264 | 281 |
265 | 282 |
266 .. |menu-icon| image:: /images/menu-icon.png | 283 .. |menu-icon| image:: /images/menu-icon.png |
267 .. |gear-icon| image:: /images/gear-icon.png | 284 .. |gear-icon| image:: /images/gear-icon.png |
OLD | NEW |