| 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="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="examples"><span id="sdk-examples-2"></s
pan>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_31</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 31 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="enable-native-client">Enable Native Client</h2> | 14 <h2 id="enable-native-client"><span id="id1"></span>Enable Native Client</h2> |
| 15 <aside class="note"> | 15 <p>If you are using Chrome 31 or later, you can skip this section. To run Portab
le |
| 16 If you are using Chrome 31 or later, you can skip this section. | 16 Native Client applications you must specifically enable Native Client in Chrome:
</p> |
| 17 </aside> | |
| 18 <p>To run Portable Native Client applications you must specifically enable Nativ
e | |
| 19 Client in Chrome:</p> | |
| 20 <ol class="arabic"> | 17 <ol class="arabic"> |
| 21 <li><p class="first">Type <code>about:flags</code> in the Chrome address bar and
scroll down to “Native | 18 <li><p class="first">Type <code>about:flags</code> in the Chrome address bar and
scroll down to “Native |
| 22 Client”.</p> | 19 Client”.</p> |
| 23 <ul class="small-gap"> | 20 <ul class="small-gap"> |
| 24 <li><p class="first">If the link below “Native Client” says “D
isable”, then Native Client is | 21 <li><p class="first">If the link below “Native Client” says “D
isable”, then Native Client is |
| 25 already enabled and you don’t need to do anything else.</p> | 22 already enabled and you don’t need to do anything else.</p> |
| 26 </li> | 23 </li> |
| 27 </ul> | 24 </ul> |
| 28 <ul class="small-gap"> | 25 <ul class="small-gap"> |
| 29 <li><p class="first">If the link below “Native Client” says “E
nable”, click the “Enable” | 26 <li><p class="first">If the link below “Native Client” says “E
nable”, click the “Enable” |
| 30 link.</p> | 27 link.</p> |
| 31 </li> | 28 </li> |
| 32 </ul> | 29 </ul> |
| 33 </li> | 30 </li> |
| 34 <li><p class="first">Scroll down to the bottom of the page, and click “Rel
aunch Now”. All browser | 31 <li><p class="first">Scroll down to the bottom of the page, and click “Rel
aunch Now”. All browser |
| 35 windows will restart when you relaunch Chrome.</p> | 32 windows will restart when you relaunch Chrome.</p> |
| 36 </li> | 33 </li> |
| 37 </ol> | 34 </ol> |
| 38 <h2 id="disable-the-chrome-cache">Disable the Chrome cache</h2> | 35 <h2 id="build-the-sdk-examples"><span id="id2"></span>Build the SDK examples</h2
> |
| 39 <p>Chrome caches resources aggressively. When you are building a Native Client | 36 <p>The Makefile scripts for the SDK examples can build multiple versions of the |
| 40 application you should disable the cache to make sure that Chrome loads the | 37 examples using any of the three SDK toolchains (newlib, glibc, and PNaCl) and in |
| 41 latest version.</p> | 38 both release and debug configurations. Note that some examples, <code>dlopen</co
de> for |
| 42 <ol class="arabic simple"> | 39 example, build only with particular toolchains.</p> |
| 43 <li>Open Chrome’s developer tools by clicking the menu icon <img alt="menu
-icon" src="/native-client/images/menu-icon.png" /> and | 40 <p>Find the toolchains for each example by looking at the <code>VALID_TOOLCHAINS
</code> |
| 44 choosing Tools > Developer tools.</li> | 41 variable in the Makefile for a particular example. The first item listed is the |
| 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 | 42 default. It’s built when you run an example make file without parameters.
for |
| 46 window.</li> | 43 example running make in the <code>core</code> directory of pepper_35 builds the
example |
| 47 <li>Under the “General” settings, check the box next to “Disab
le cache”.</li> | 44 using the <code>newlib</code> toolchain.</p> |
| 48 </ol> | |
| 49 <h2 id="build-the-sdk-examples">Build the SDK examples</h2> | |
| 50 <p>The Makefile scripts for the SDK examples build multiple versions of the | |
| 51 examples using all three SDK toolchains (newlib, glibc, and PNaCl) and in both | |
| 52 release and debug configurations. (Note that some examples build only with | |
| 53 particular toolchains).</p> | |
| 54 <h3 id="build-all-examples">Build all examples</h3> | |
| 55 <p>To build all the examples, go to the examples directory in a specific SDK | |
| 56 bundle and run <code>make</code>:</p> | |
| 57 <pre class="prettyprint"> | 45 <pre class="prettyprint"> |
| 58 $ cd pepper_31/examples | 46 $ cd pepper_35/examples/api/core |
| 59 $ make | 47 $ make |
| 60 make -C api all | 48 CXX newlib/Release/core_x86_32.o |
| 61 make[1]: Entering directory `pepper_31/examples/api' | 49 LINK newlib/Release/core_unstripped_x86_32.nexe |
| 62 make -C audio all | 50 VALIDATE newlib/Release/core_unstripped_x86_32.nexe |
| 63 make[2]: Entering directory `pepper_31/examples/api/audio' | 51 CXX newlib/Release/core_x86_64.o |
| 64 CXX newlib/Debug/audio_x86_32.o | 52 LINK newlib/Release/core_unstripped_x86_64.nexe |
| 65 LINK newlib/Debug/audio_x86_32.nexe | 53 VALIDATE newlib/Release/core_unstripped_x86_64.nexe |
| 66 CXX newlib/Debug/audio_x86_64.o | 54 CXX newlib/Release/core_arm.o |
| 67 LINK newlib/Debug/audio_x86_64.nexe | 55 LINK newlib/Release/core_unstripped_arm.nexe |
| 68 CXX newlib/Debug/audio_arm.o | 56 VALIDATE newlib/Release/core_unstripped_arm.nexe |
| 69 LINK newlib/Debug/audio_arm.nexe | 57 STRIP newlib/Release/core_x86_32.nexe |
| 70 CREATE_NMF newlib/Debug/audio.nmf | 58 STRIP newlib/Release/core_x86_64.nexe |
| 71 make[2]: Leaving directory `pepper_31/examples/api/audio' | 59 STRIP newlib/Release/core_arm.nexe |
| 72 make -C url_loader all | 60 CREATE_NMF newlib/Release/core.nmf |
| 73 make[2]: Entering directory `pepper_31/examples/api/url_loader' | |
| 74 CXX newlib/Debug/url_loader_x86_32.o | |
| 75 ... | |
| 76 </pre> | 61 </pre> |
| 77 <h3 id="build-a-single-example">Build a single example</h3> | 62 <p>As you can see, this produces a number of architecture specific nexe files in |
| 78 <p>Calling <code>make</code> from inside a particular example’s directory
will build only | 63 the <code>pepper_35/examples/api/core/Release</code> directory. Create debug ve
rsions by |
| 79 that example:</p> | 64 using the <code>CONFIG</code> parameter of the make command.</p> |
| 80 <pre class="prettyprint"> | 65 <pre class="prettyprint"> |
| 81 $ cd pepper_31/examples/api/core | 66 $make CONFIG=Debug |
| 82 $ make | |
| 83 CXX newlib/Debug/core_x86_32.o | |
| 84 LINK newlib/Debug/core_x86_32.nexe | |
| 85 CXX newlib/Debug/core_x86_64.o | |
| 86 LINK newlib/Debug/core_x86_64.nexe | |
| 87 CXX newlib/Debug/core_arm.o | |
| 88 LINK newlib/Debug/core_arm.nexe | |
| 89 CREATE_NMF newlib/Debug/core.nmf | |
| 90 </pre> | 67 </pre> |
| 91 <h3 id="override-defaults">Override defaults</h3> | 68 <p>This creates similar output, but in <code>pepper_35/examples/api/core/Debug</
code>.</p> |
| 92 <p>You can call <code>make</code> with the <code>TOOLCHAIN</code> and <code>CONF
IG</code> parameters to | 69 <p>Select a different toolchain with the <code>TOOLCHAIN</code> parameter. For
example:</p> |
| 93 override the defaults:</p> | |
| 94 <pre class="prettyprint"> | 70 <pre class="prettyprint"> |
| 71 $ cd pepper_35/examples/api/core |
| 95 $ make TOOLCHAIN=pnacl CONFIG=Release | 72 $ make TOOLCHAIN=pnacl CONFIG=Release |
| 96 CXX pnacl/Release/core_pnacl.o | 73 CXX pnacl/Release/core.o |
| 97 LINK pnacl/Release/core.bc | 74 LINK pnacl/Release/core_unstripped.bc |
| 98 FINALIZE pnacl/Release/core.pexe | 75 FINALIZE pnacl/Release/core_unstripped.pexe |
| 99 CREATE_NMF pnacl/Release/core.nmf | 76 CREATE_NMF pnacl/Release/core.nmf |
| 100 </pre> | 77 </pre> |
| 101 <p>You can also set <code>TOOLCHAIN</code> to “all” to build one or
more examples with | 78 <p>You can also set <code>TOOLCHAIN</code> to <code>all</code> to build all Rele
ase versions with |
| 102 all available toolchains:</p> | 79 default toolchains.</p> |
| 103 <pre class="prettyprint"> | 80 <pre class="prettyprint"> |
| 81 $ cd pepper_35/examples/api/core |
| 104 $ make TOOLCHAIN=all | 82 $ make TOOLCHAIN=all |
| 105 make TOOLCHAIN=newlib | 83 make TOOLCHAIN=newlib |
| 106 make[1]: Entering directory `pepper_31/examples/api/core' | 84 make[1]: Entering directory 'pepper_35/examples/api/core' |
| 107 CXX newlib/Debug/core_x86_32.o | 85 CXX newlib/Release/core_x86_32.o |
| 108 LINK newlib/Debug/core_x86_32.nexe | 86 LINK newlib/Release/core_unstripped_x86_32.nexe |
| 109 CXX newlib/Debug/core_x86_64.o | 87 VALIDATE newlib/Release/core_unstripped_x86_32.nexe |
| 110 LINK newlib/Debug/core_x86_64.nexe | 88 CXX newlib/Release/core_x86_64.o |
| 111 CXX newlib/Debug/core_arm.o | 89 LINK newlib/Release/core_unstripped_x86_64.nexe |
| 112 LINK newlib/Debug/core_arm.nexe | 90 VALIDATE newlib/Release/core_unstripped_x86_64.nexe |
| 113 CREATE_NMF newlib/Debug/core.nmf | 91 CXX newlib/Release/core_arm.o |
| 114 make[1]: Leaving directory `pepper_31/examples/api/core' | 92 LINK newlib/Release/core_unstripped_arm.nexe |
| 93 VALIDATE newlib/Release/core_unstripped_arm.nexe |
| 94 STRIP newlib/Release/core_x86_32.nexe |
| 95 STRIP newlib/Release/core_x86_64.nexe |
| 96 STRIP newlib/Release/core_arm.nexe |
| 97 CREATE_NMF newlib/Release/core.nmf |
| 98 make[1]: Leaving directory 'pepper_35/examples/api/core' |
| 115 make TOOLCHAIN=glibc | 99 make TOOLCHAIN=glibc |
| 116 make[1]: Entering directory `pepper_31/examples/api/core' | 100 make[1]: Entering directory 'pepper_35/examples/api/core' |
| 117 CXX glibc/Debug/core_x86_32.o | 101 CXX glibc/Release/core_x86_32.o |
| 118 LINK glibc/Debug/core_x86_32.nexe | 102 LINK glibc/Release/core_unstripped_x86_32.nexe |
| 119 CXX glibc/Debug/core_x86_64.o | 103 VALIDATE glibc/Release/core_unstripped_x86_32.nexe |
| 120 LINK glibc/Debug/core_x86_64.nexe | 104 CXX glibc/Release/core_x86_64.o |
| 121 CREATE_NMF glibc/Debug/core.nmf | 105 LINK glibc/Release/core_unstripped_x86_64.nexe |
| 122 make[1]: Leaving directory `pepper_31/examples/api/core' | 106 VALIDATE glibc/Release/core_unstripped_x86_64.nexe |
| 123 make TOOLCHAIN=pnacl | 107 ... |
| 124 make[1]: Entering directory `pepper_31/examples/api/core' | 108 (content excerpted) |
| 125 CXX pnacl/Debug/core.o | 109 ... |
| 126 LINK pnacl/Debug/core_unstripped.bc | |
| 127 FINALIZE pnacl/Debug/core_unstripped.pexe | |
| 128 CREATE_NMF pnacl/Debug/core.nmf | |
| 129 make[1]: Leaving directory `pepper_31/examples/api/core' | |
| 130 make TOOLCHAIN=linux | |
| 131 make[1]: Entering directory `pepper_31/examples/api/core' | |
| 132 CXX linux/Debug/core.o | |
| 133 LINK linux/Debug/core.so | |
| 134 make[1]: Leaving directory `pepper_31/examples/api/core' | |
| 135 </pre> | 110 </pre> |
| 136 <h2 id="build-results">Build results</h2> | 111 <h3 id="build-results"><span id="id3"></span>Build results</h3> |
| 137 <p>After running <code>make</code>, each example directory will contain one or m
ore of | 112 <p>After running <code>make</code>, example directories will contain one or more
of the |
| 138 the following subdirectories:</p> | 113 following subdirectories, depending on which Makefile you run:</p> |
| 139 <ul class="small-gap"> | 114 <ul class="small-gap"> |
| 140 <li><code>newlib</code> with subdirectories <code>Debug</code> and <code>Release
</code>;</li> | 115 <li><code>newlib</code> with subdirectories <code>Debug</code> and <code>Release
</code>;</li> |
| 141 <li><code>glibc</code> with subdirectories <code>Debug</code> and <code>Release<
/code>;</li> | 116 <li><code>glibc</code> with subdirectories <code>Debug</code> and <code>Release<
/code>;</li> |
| 142 <li><code>pnacl</code> with subdirectories <code>Debug</code> and <code>Release<
/code>;</li> | 117 <li><code>pnacl</code> with subdirectories <code>Debug</code> and <code>Release<
/code>;</li> |
| 143 </ul> | 118 </ul> |
| 144 <p>For the newlib and glibc toolchains the Debug and Release subdirectories | 119 <p>For the newlib and glibc toolchains the Debug and Release subdirectories |
| 145 contain .nexe files for all target architectures. For the PNaCl toolchain | 120 contain .nexe files for all target architectures. For the PNaCl toolchain |
| 146 they contain a single .pexe file. PNaCl debug also produces pre-translated | 121 they contain a single .pexe file. PNaCl debug also produces pre-translated |
| 147 .nexe files, for ease of debugging. All Debug and Release directories contain | 122 .nexe files, for ease of debugging. All Debug and Release directories contain |
| 148 a manifest (.nmf) file that references the associated .nexe or .pexe files. | 123 a manifest (.nmf) file that references the associated .nexe or .pexe files. |
| 149 For information about Native Client manifest files, see the <a class="reference
internal" href="/native-client/overview.html"><em>Technical | 124 For information about Native Client manifest files, see the <a class="reference
internal" href="/native-client/overview.html"><em>Technical |
| 150 Overview</em></a>.</p> | 125 Overview</em></a>.</p> |
| 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 | 126 <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 |
| 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> | 127 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> |
| 153 <h2 id="run-the-sdk-examples"><span id="id1"></span>Run the SDK examples</h2> | 128 <h2 id="run-the-sdk-examples"><span id="running-the-sdk-examples"></span>Run the
SDK examples</h2> |
| 154 <p>To run the SDK examples, you can use the <code>make run</code> command:</p> | 129 <h3 id="disable-the-chrome-cache"><span id="disable-chrome-cache"></span>Disable
the Chrome cache</h3> |
| 130 <p>Chrome’s intelligent caching caches resources aggressively. When buildi
ng a |
| 131 Native Client application you should disable the cache to make sure that Chrome |
| 132 loads the latest version. Intelligent caching only remains inactive while |
| 133 Developer Tools are open. Otherwise, agressive caching continues.</p> |
| 134 <ol class="arabic simple"> |
| 135 <li>Open Chrome’s developer tools by clicking the menu icon <img alt="menu
-icon" src="/native-client/images/menu-icon.png" /> and |
| 136 choosing Tools > Developer tools.</li> |
| 137 <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 |
| 138 window.</li> |
| 139 <li>Under the “General” settings, check the box next to “Disab
le cache”.</li> |
| 140 </ol> |
| 141 <h3 id="run-the-examples"><span id="id4"></span>Run the examples</h3> |
| 142 <p>To run the SDK examples, use the <code>make run</code> command:</p> |
| 155 <pre class="prettyprint"> | 143 <pre class="prettyprint"> |
| 156 $ cd pepper_31/examples/api/core | 144 $ cd pepper_35/examples/api/core |
| 157 $ make run | 145 $ make run |
| 158 </pre> | 146 </pre> |
| 159 <p>This will launch a local HTTP server which will serve the data for the | 147 <p>This launches a local HTTP server that serves the example. It then launches |
| 160 example. It then launches Chrome with the address of this server, usually | 148 Chrome with the address of this server, usually <code>http://localhost:5103</cod
e>. |
| 161 <code>http://localhost:5103</code>. After you close Chrome, the local HTTP serve
r is | 149 After you close Chrome, the local HTTP server automatically shuts down.</p> |
| 162 automatically shutdown.</p> | 150 <p>This command tries to find an executable named <code>google-chrome</code> in
your |
| 163 <p>This command will try to find an executable named <code>google-chrome</code>
in your | |
| 164 <code>PATH</code> environment variable. If it can’t, you’ll get an e
rror message like | 151 <code>PATH</code> environment variable. If it can’t, you’ll get an e
rror message like |
| 165 this:</p> | 152 this:</p> |
| 166 <pre class="prettyprint"> | 153 <pre class="prettyprint"> |
| 167 pepper_31/tools/common.mk:415: No valid Chrome found at CHROME_PATH= | 154 pepper_35/tools/common.mk:415: No valid Chrome found at CHROME_PATH= |
| 168 pepper_31/tools/common.mk:415: *** Set CHROME_PATH via an environment variable,
or command-line.. Stop. | 155 pepper_35/tools/common.mk:415: *** Set CHROME_PATH via an environment variable,
or command-line.. Stop. |
| 169 </pre> | 156 </pre> |
| 157 <h3 id="add-an-environment-variable-for-chrome"><span id="add-an-env-variable-fo
r-chrome"></span>Add an environment variable for Chrome</h3> |
| 170 <p>Set the CHROME_PATH environment variable to the location of your Chrome | 158 <p>Set the CHROME_PATH environment variable to the location of your Chrome |
| 171 executable.</p> | 159 executable.</p> |
| 172 <ul class="small-gap"> | 160 <ul class="small-gap"> |
| 173 <li><p class="first">On Windows:</p> | 161 <li><p class="first">On Windows:</p> |
| 174 <p>The default install location of Chrome is | 162 <p>The default install location of Chrome is |
| 175 <code>C:\Program Files (x86)\Google\Chrome\Application\chrome.exe</code> for Chr
ome | 163 <code>C:\Program Files (x86)\Google\Chrome\Application\chrome.exe</code> for Chr
ome |
| 176 stable and | 164 stable and |
| 177 <code>C:\Users\<username>\AppData\Local\Google\Chrome SxS\Application\chro
me.exe</code> | 165 <code>C:\Users\<username>\AppData\Local\Google\Chrome SxS\Application\chro
me.exe</code> |
| 178 for Chrome Canary; try looking in those directories first:</p> | 166 for Chrome Canary. Try looking in those directories first:</p> |
| 179 <pre class="prettyprint"> | 167 <pre class="prettyprint"> |
| 180 > set CHROME_PATH=<Path to chrome.exe> | 168 > set CHROME_PATH=<Path to chrome.exe> |
| 181 </pre> | 169 </pre> |
| 182 </li> | 170 </li> |
| 183 <li><p class="first">On Linux:</p> | 171 <li><p class="first">On Linux:</p> |
| 184 <pre class="prettyprint"> | 172 <pre class="prettyprint"> |
| 185 $ export CHROME_PATH=<Path to google-chrome> | 173 $ export CHROME_PATH=<Path to google-chrome> |
| 186 </pre> | 174 </pre> |
| 187 </li> | 175 </li> |
| 188 <li><p class="first">On Mac:</p> | 176 <li><p class="first">On Mac:</p> |
| 189 <p>The default install location of Chrome is | 177 <p>The default install location of Chrome is |
| 190 <code>/Applications/Google Chrome.app/Contents/MacOS/Google Chrome</code> for | 178 <code>/Applications/Google Chrome.app/Contents/MacOS/Google Chrome</code> for |
| 191 Chrome Stable and | 179 Chrome Stable and |
| 192 <code>Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary<
/code> | 180 <code>Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary<
/code> |
| 193 for Chrome Canary. Note that you have to reference the executable inside the | 181 for Chrome Canary. Note that you have to reference the executable inside the |
| 194 application bundle, not the top-level <code>.app</code> directory:</p> | 182 application bundle, not the top-level <code>.app</code> directory:</p> |
| 195 <pre class="prettyprint"> | 183 <pre class="prettyprint"> |
| 196 $ export CHROME_PATH=<Path to Google Chrome> | 184 $ export CHROME_PATH=<Path to Google Chrome> |
| 197 </pre> | 185 </pre> |
| 198 </li> | 186 </li> |
| 199 </ul> | 187 </ul> |
| 200 <p>You can run via a different toolchain or configuration by using the | |
| 201 <code>TOOLCHAIN</code> and <code>CONFIG</code> parameters to make:</p> | |
| 202 <pre class="prettyprint"> | |
| 203 $ make run TOOLCHAIN=pnacl CONFIG=Debug | |
| 204 </pre> | |
| 205 <h2 id="run-the-sdk-examples-as-packaged-apps"><span id="run-sdk-examples-as-pac
kaged"></span>Run the SDK examples as packaged apps</h2> | 188 <h2 id="run-the-sdk-examples-as-packaged-apps"><span id="run-sdk-examples-as-pac
kaged"></span>Run the SDK examples as packaged apps</h2> |
| 206 <p>Each example can also be launched as a packaged app. For more information abo
ut | 189 <p>Each example can also be launched as a packaged application. A packaged |
| 207 using Native Client for packaged apps, see <a class="reference internal" href="/
native-client/devguide/distributing.html#distributing-packaged"><em>Packaged app
lication</em></a>. For general information about packaged apps, see the | 190 application is a special zip file (with a .crx extension) hosted in the Chrome |
| 208 <a class="reference external" href="/apps/about_apps">Chrome apps documentation<
/a>.</p> | 191 Web Store. This file contains all of the application parts: A Chrome Web Store |
| 192 manifest file (manifest.json), an icon, and all of the regular Native Client |
| 193 application files. Refer to <a class="reference external" href="/apps/about_apps
">What are Chrome Apps</a> for more |
| 194 information about creating a packaged application.</p> |
| 209 <p>Some Pepper features, such as TCP/UDP socket access, are only allowed in | 195 <p>Some Pepper features, such as TCP/UDP socket access, are only allowed in |
| 210 packaged apps. The examples that use these features must be run as packaged | 196 packaged applications. The examples that use these features must be run as |
| 211 apps, by using the <code>make run_package</code> command:</p> | 197 packaged applications, by using the following command:</p> |
| 212 <pre class="prettyprint"> | 198 <pre class="prettyprint"> |
| 213 $ make run_package | 199 $ make run_package |
| 214 </pre> | 200 </pre> |
| 215 <p>You can use <code>TOOLCHAIN</code> and <code>CONFIG</code> parameters as abov
e to run with a | 201 <p>You can use <code>TOOLCHAIN</code> and <code>CONFIG</code> parameters as desc
ribed above to run |
| 216 different toolchain or configuration.</p> | 202 with a different toolchain or configuration.</p> |
| 217 <h2 id="debugging-the-sdk-examples"><span id="id2"></span>Debugging the SDK exam
ples</h2> | 203 <h2 id="debugging-the-sdk-examples"><span id="id5"></span>Debugging the SDK exam
ples</h2> |
| 218 <p>The NaCl SDK uses <a class="reference external" href="https://www.gnu.org/sof
tware/gdb/">GDB</a> to debug Native | 204 <p>The NaCl SDK uses <a class="reference external" href="https://www.gnu.org/sof
tware/gdb/">GDB</a> to debug Native |
| 219 Client code. The SDK includes a prebuilt version of GDB that is compatible with | 205 Client code. The SDK includes a prebuilt version of GDB that is compatible with |
| 220 NaCl code. To use it, run the <code>make debug</code> command from an example di
rectory:</p> | 206 NaCl code. To use it, run the <code>make debug</code> command from an example di
rectory:</p> |
| 221 <pre class="prettyprint"> | 207 <pre class="prettyprint"> |
| 222 $ make debug | 208 $ make debug |
| 223 </pre> | 209 </pre> |
| 224 <p>This will launch Chrome with the <code>--enable-nacl-debug</code> flag set. T
his flag | 210 <p>This launches Chrome with the <code>--enable-nacl-debug</code> flag set. This
flag causes |
| 225 will cause Chrome to pause when a NaCl module is first loaded, waiting for a | 211 Chrome to pause when a NaCl module is first loaded, waiting for a connection |
| 226 connection from gdb. The <code>make debug</code> command also simultaneously lau
nches | 212 from gdb. The <code>make debug</code> command also simultaneously launches GDB a
nd loads |
| 227 GDB and loads the symbols for that NEXE. To connect GDB to Chrome, in the GDB | 213 the symbols for that NEXE. To connect GDB to Chrome, in the GDB console, type:</
p> |
| 228 console, type:</p> | |
| 229 <pre class="prettyprint"> | 214 <pre class="prettyprint"> |
| 230 (gdb) target remote :4014 | 215 (gdb) target remote :4014 |
| 231 </pre> | 216 </pre> |
| 232 <p>This tells GDB to connect to a TCP port on <code>localhost:4014</code>–
the port that | 217 <p>This tells GDB to connect to a TCP port on <code>localhost:4014</code>, the p
ort that |
| 233 Chrome is listening on. GDB will respond:</p> | 218 Chrome is listening on. GDB will respond:</p> |
| 234 <pre class="prettyprint"> | 219 <pre class="prettyprint"> |
| 235 Remote debugging using :4014 | 220 Remote debugging using :4014 |
| 236 0x000000000fa00080 in ?? () | 221 0x000000000fa00080 in ?? () |
| 237 </pre> | 222 </pre> |
| 238 <p>At this point, you can use the standard GDB commands to debug your NaCl modul
e. | 223 <p>At this point, you can use the standard GDB commands to debug your NaCl modul
e. |
| 239 The most common commands you will use to debug are <code>continue</code>, <code>
step</code>, | 224 The most common commands you will use to debug are <code>continue</code>, <code>
step</code>, |
| 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 | 225 <code>next</code>, <code>break</code> and <code>backtrace</code>. See |
| 241 application.</p> | 226 <a class="reference internal" href="/native-client/devguide/devcycle/debugging.h
tml"><em>Debugging</em></a> for more information about |
| 227 debugging a Native Client application.</p> |
| 242 </section> | 228 </section> |
| 243 | 229 |
| 244 {{/partials.standard_nacl_article}} | 230 {{/partials.standard_nacl_article}} |
| OLD | NEW |