1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns=
"http://www.w3.org/1999/xhtml">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8" />
5 <title>Native Client: Getting Started
</title>
6 <link href=
"stylesheet.css" type=
"text/css" rel=
"stylesheet"></link>
12 <a href=
"../README.html">Back to README
</a>
15 <h1>Getting Started
</h1>
18 This page tells you how to install Native Client
20 both in and outside of the browser.
21 On Linux and Mac OS X,
22 you can also recompile demos
23 and run them as standalone applications.
29 <li> <a href=
"#software">Get the software
</a> </li>
30 <li> <a href=
"#example-nacl">Run an example as a Native Client app
</a></li>
31 <li> <a href=
"#plugin">Install and use the plug-in
</a></li>
32 <li> <a href=
"#make">Use make to compile and run standalone examples (Linux or Mac)
</a></li>
33 <li> <a href=
"#next">What next?
</a>
36 <h2><a name=
"software" id=
"software"></a>Get the software
</h2>
39 To run the examples as Native Client modules,
40 you need Native Client, Python,
42 we recommend Firefox
3.
43 If you want to develop your own Native Client modules,
44 you'll also need platform-specific development tools
45 such as Xcode on the Mac and Visual Studio on Windows,
47 the
<a href=
"#make">make section
</a>
49 <a href=
"building.html">Building Native Client
</a>.
53 <b>Technical detail:
</b>
54 Native Client doesn't itself require Python.
55 We use Python for scripts
56 such as those that build and run examples
57 and that install the Native Client plug-in.
58 We're working on simpler installers that don't require Python.
62 Here's how to install Native Client and Python.
69 Choose an installation directory (
<em>install_dir
</em>).
70 Because Native Client is frequently updated,
71 you might want a path that indicates the download or build date.
76 <code>/home/me/NaCl/Testing/
2009-
02-
11 </code> <em>(Linux)
</em>
79 <code>/Users/me/NaCl/Testing/
2009-
02-
11 </code> <em>(Mac)
</em>
82 <code>C:\NaCl\Testing\
2009-
02-
11 </code> <em>(Windows)
</em>
88 Make sure the full path of
<em>install_dir
</em> contains
<b>no spaces
</b>.
94 <a href=
"http://code.google.com/p/nativeclient/wiki/Downloads?tm=2">Download
</a>
95 the Native Client
<code>.tgz
</code> or
<code>.zip
</code> file for your platform.
100 Extract the files into
<em>install_dir
</em>.
105 <pre class=
"platform-linux">
106 <kbd>tar xvf nacl_linux*.tgz
</kbd>
110 <pre class=
"platform-mac">
111 <kbd>tar xvf nacl_mac*.tgz
</kbd>
118 Do
<em>not
</em> use Cygwin unzip.
119 Instead, you can use the built-in Windows support or
7-Zip.
120 For example: In the file manager,
121 right-click the
<code>nacl_windows_*.zip file
</code>
122 and choose Extract All.
128 Test your version of Python.
131 <pre class=
"platform-all">
132 <kbd>python -V
</kbd> <em>#Note: That's an uppercase 'V'
</em>
136 The output should be something like
137 <code>Python
2.4.3</code>.
138 If your system can't find
<code>python
</code>
139 or the version isn't
2.4 or
2.5,
140 get the right version of Python
141 and make sure it's in your path.
143 <a href=
"building.html">Native Client build instructions
</a>.
147 <b>Do not use Cygwin's version of Python
</b>.
148 Instead, use the standard Python distribution.
150 <a href=
"building.html#setup-windows">Windows setup instructions
</a>.
157 <h2><a name=
"example-nacl" id=
"example-nacl"></a>Run an example as a Native Client app
</h2>
160 Now you'll learn how to run an example app in Native Client.
164 <b>Technical detail:
</b>
165 You might be wondering why we start you off with a command-line application,
166 rather than with the browser.
167 The reason is that when you create your own Native Client modules,
168 it's easier to get started
169 if you're working outside the browser.
175 In a terminal window, go to the earth demo's directory.
182 <pre class=
"platform-linux-mac">
183 <kbd>cd
<em>install_dir
</em>/nacl/googleclient/native_client/tests/earth
</kbd>
190 <pre class=
"platform-windows">
191 <kbd>cd
<em>install_dir
</em>\nacl\googleclient\native_client\tests\earth
</kbd>
197 Run the earth demo as a Native Client application.
198 The command is the same on all platforms:
202 <pre class=
"platform-all">
203 <kbd>python run.py
</kbd>
207 A window should appear
208 that contains a spinning, ray-traced globe.
209 The title of the window,
<b>NaCl Application
</b>,
210 indicates that you're running a Native Client module in a dedicated process.
213 <img src=
"images/NaClApp.jpg"
214 width=
"512" height=
"534"
215 alt=
"screenshot of the earth demo" />
216 <div class=
"caption">Figure: The earth demo running as a Native Client app (on Mac)
</span></div>
219 You can quit the earth demo by clicking the close (X) button
221 Or just wait; it quits automatically
222 after displaying
10000 frames.
226 <b>Troubleshooting:
</b>
228 and you get a message starting with
229 <code>ERROR: Cannot find Native Client executable
</code>,
230 you've probably downloaded the source-only distribution of Native Client.
232 <a href=
"http://code.google.com/p/nativeclient/wiki/Downloads?tm=2">download the distribution for your platform
</a>
233 (Linux, Mac, or Windows)
234 or
<a href=
"building.html">build Native Client and its SDK
</a>.
238 [PENDING: What other problems have people run into?]
243 <h2><a name=
"plugin" id=
"plugin"> </a> Install and use the plug-in
</h2>
246 Now it's time to run some Native Client modules inside a browser.
247 To do so, you need to install the Native Client plug-in
248 and then load a page that refers to one or more Native Client modules.
254 Go to the
<code>native_client
</code> directory:
261 <pre class=
"platform-linux-mac">
262 <kbd>cd
<em>install_dir
</em>/nacl/googleclient/native_client
</kbd>
269 <pre class=
"platform-windows">
270 <kbd>cd
<em>install_dir
</em>\nacl\googleclient\native_client
</kbd>
277 both
<a href=
"http://nativeclient.googlecode.com/svn/trunk/nacl/googleclient/native_client/documentation/getting_started.html">online
</a>
278 and in your Native Client distribution
279 (
<em>install_dir
</em>/nacl/googleclient/native_client/documentation/getting_started.html
</b>).
280 The bookmarks will make it easier for you to get back to these instructions
281 after restarting your browser.
282 Consider printing out this page, as well,
283 or saving these instructions to a text or PDF file.
289 Exit Firefox if you're running it.
290 Also exit any other browsers that might have run a Native Client module.
291 The plug-in might not install correctly if Firefox is running
292 or if any other browser is running a Native Client module.
299 Answer
<b>y
</b> when asked whether you want to continue.
306 <pre class=
"platform-linux-mac">
307 <kbd>./scons --prebuilt firefox_install
</kbd>
309 Okay to continue? [y/n]
<kbd>y
</kbd>
314 <b>Technical detail:
</b>
315 The
<code>--prebuilt
</code> option
316 isn't strictly necessary,
317 but it makes the install go much more quickly.
318 Without it, SCons attempts to rebuild some of the Native Client binaries.
323 If you're using a
64-bit Linux system,
324 we recommend that you use a
32-bit browser.
325 For instructions, search for
326 [
<a href=
"http://www.google.com/search?&q=linux+32-bit+64-bit+browser">linux
32-bit
64-bit browser
</a>].
327 <em>If you're adventurous
</em>
328 and your modules don't use NPAPI,
329 then you might be able to instead use
330 <a href=
"http://gwenole.beauchesne.info/en/projects/nspluginwrapper">NSPluginWrapper
</a>
331 (version
1.1.2 or newer)
332 to make the Native Client plug-in work
334 Don't use NSPluginWrapper if your modules depend on NPAPI;
335 the performance impact of NSPluginWrapper's NPAPI forwarding can be huge.
342 <pre class=
"platform-windows">
343 <kbd>.\scons.bat --prebuilt firefox_install
</kbd>
345 Okay to continue? [y/n]
<kbd>y
</kbd>
352 you can't use SCons to install the plug-in on Vista.
353 Instead, you need to copy three files into
354 <code>C:\Program Files\Mozilla Firefox\plugins
</code>:
358 <li> <code><em>install_dir
</em>\nacl\googleclient\native_client\scons-out\opt-win\staging\
<b>npGoogleNaClPlugin.dll
</b></code> </li>
359 <li> <code><em>install_dir
</em>\nacl\googleclient\native_client\scons-out\opt-win\staging\
<b>SDL.dll
</b></code> </li>
360 <li> <code><em>install_dir
</em>\nacl\googleclient\native_client\scons-out\opt-win\staging\
<b>sel_ldr.exe
</b></code> </li>
364 [PENDING: Troubleshoot any likely problems.]
370 Look at the installer output
371 to make sure the installation was successful.
383 In Firefox, look at the following file:
387 <a href=
"../scons-out/nacl/staging/index.html"><code><em>install_dir
</em>/nacl/googleclient/native_client/scons-out/nacl/staging/index.html
</code></a>
392 That link works only if you're viewing this page
393 within the Native Client distribution, at
394 <code><em>install_dir
</em>/nacl/googleclient/native_client/documentation/getting_started.html
</code>.
399 Click the bottom-left link to go to the Mandelbrot viewer page.
400 This page has a Native Client implementation
401 of a Mandelbrot drawing.
402 You should see something like this:
406 <img src=
"images/mandelbrot.jpg"
407 width=
"587" height=
"536"
409 alt=
"screenshot of the Mandelbrot viewer demo" />
410 <div class=
"caption">Figure: The Mandelbrot viewer demo
</div>
415 You can click the Cycle Colors button to see an everchanging display of colors.
416 Press and hold the + button to zoom in.
417 Use the arrows on the large round button to
418 change which part of the Mandelbrot you can see.
426 For information about the other demos you can run in your browser, see
427 <a href=
"examples.html">Examples and Tests
</a>.
430 <h2><a name=
"make" id=
"make"> </a> Use make to compile and run standalone examples (Linux or Mac)
</h2>
433 In this section, you'll use GNU
<code>make
</code>
434 to compile and run the same example that you've already run.
435 First, you'll make a version that runs as a standalone application.
436 Next, you'll use
<code>make
</code>
437 to recompile the example and run it again as a Native Client app,
438 using the binaries that you created instead of prebuilt binaries.
439 Finally, you'll use
<code>make clean
</code>
440 and run the Native Client app again using the prebuilt binaries.
444 <b>Technical detail:
</b>
445 The standard build tool for Native Client is
447 You can compile our examples (on any platform) using SCons,
448 following the instructions in
449 <a href=
"building.html">Building Native Client
</a>.
450 The Makefiles exist so that
451 you can more easily use our examples
452 as templates for your own programs,
453 and so you can run our examples
454 as either Native Client or standalone applications (on Linux and Mac).
455 Running a module as a standalone application
456 can be handy when you're
457 <a href=
"debugging.html">debugging
</a>.
461 To perform the steps in this section,
462 your development environment needs to be set up
463 as described in the build instructions for your platform
—
464 <a href=
"building.html#setup-linux">Setup: Linux
</a> or
465 <a href=
"building.html#setup-mac">Setup: Mac OS X
</a>.
466 Native Client doesn't support
<code>make
</code> or standalone apps on Windows.
472 In a terminal window, go to the earth demo's directory:
475 <pre class=
"platform-linux-mac">
476 <kbd>cd
<em>install_dir
</em>/nacl/googleclient/native_client/tests/earth
</kbd>
482 Recompile the demo as a standalone application and run it.
485 <pre class=
"platform-linux-mac">
486 <kbd>make debug run
</kbd>
491 you should see a window with
493 This time, the title of the window is
<b>Standalone Application
</b>.
494 You'll also see the
<code>g++
</code> command
495 used to compile the demo as an app.
499 [PENDING: Troubleshoot any likely problems
— e.g. make missing
500 on a Mac that doesn't have Xcode installed.]
506 Recompile the demo as a Native Client module and run it again:
509 <pre class=
"platform-linux-mac">
510 <kbd>make release nacl run
</kbd>
514 Again you should see a spinning globe
515 with the title
<b>NaCl Application
</b>.
516 You'll also see the
<code>nacl-g++
</code> command
517 that compiles the demo
518 and the
<code>sel_ldr
</code> command
519 that runs it in the Native Client environment.
524 Remove the binaries you built,
525 and use the prebuilt binaries
526 to run the example again as a Native Client module.
529 <pre class=
"platform-linux-mac">
530 <kbd>make clean
</kbd>
531 <kbd>python run.py
</kbd>
535 You can still run the example after running
<code>make clean
</code>
536 because the Makefile refers to binaries in the current directory.
537 The Python script, on the other hand,
539 that are in the
<code>scons-out/nacl/staging
</code> directory
540 (which is under
<code>nacl/googleclient/native_client
</code>).
541 The binaries under
<code>scons-out
</code>
542 are prebuilt for you,
543 but you can always rebuild using SCons,
545 <a href=
"building.html">Building Native Client
</a>.
551 <h2><a name=
"next" id=
"next"></a>What next?
</h2>
559 <a href=
"examples.html">examples and tests
</a>.
</li>
560 <li> <a href=
"building.html">Build Native Client
</a>
562 <li> Build Quake and XaoS for Native Client;
564 For instructions, see the
<code>README.nacl
</code> files under
565 <code>nacl/googleclient/native_client/tests/quake
</code> and
566 <code>nacl/googleclient/native_client/tests/xaos
</code>.
</li>
567 <li> Browse the
<a href=
"../README.html">documentation
</a>, including the
568 <a href=
"nacl_paper.pdf">Native Client paper
</a> [PDF].
</li>
569 <li> Browse the project site,
570 <a href=
"http://code.google.com/p/nativeclient">http://code.google.com/p/nativeclient
</a>,
572 <a href=
"http://code.google.com/p/nativeclient/wiki">wiki
</a>.
</li>
576 For even more fun, consider:
580 <li> Port existing open-source packages to run as
581 Native Client module components.
</li>
582 <li> Write new Native Client modules that use
583 Native Client's reduced system call interface, NPAPI, and SRPC
584 to communicate with the browser.
</li>
585 <li> Defeat the NaCl sandbox.
586 Can you create a NaCl module
587 that creates a file in the local file system
588 or otherwise directly executes a system call?
589 Exploits using
<code>sel_ldr
</code> from the command line
590 or from the browser plug-in are both of interest.
591 Don't use the
<code>-d
</code> debug flag
—
592 that would be too easy.
593 For more suggestions and details,
595 <a href=
"http://code.google.com/p/nativeclient/wiki/WhatToTest">WhatToTest
</a>.
600 And please participate in the Native Client community:
605 <a href=
"http://groups.google.com/group/native-client-discuss">discussion
607 <a href=
"http://groups.google.com/group/native-client-announce">announcement
609 <li> <a href=
"http://code.google.com/p/nativeclient/issues">File issues
</a>
610 about any Native Client problems you've noticed
611 or features you'd like.
</li>
616 <a href=
"http://code.google.com/policies.html#restrictions">noted
</a>,
617 the content of this page is licensed under a
618 <a href=
"http://creativecommons.org/licenses/by/2.5/">Creative Commons
619 Attribution
2.5 license
</a>.