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.
46 <b>Technical detail:
</b>
47 Native Client doesn't itself require Python.
48 We use Python for scripts
49 such as those that build and run examples
50 and that install the Native Client plug-in.
51 We're working on simpler installers that don't require Python.
55 To develop your own Native Client modules,
56 you also need platform-specific development tools
57 such as Xcode on the Mac and Visual Studio on Windows,
59 the
<a href=
"#make">make section
</a>
61 <a href=
"building.html">Building Native Client
</a>.
65 Here's how to install Native Client and Python:
72 Get the Native Client .tgz or .zip file for your platform,
73 and extract the files.
77 <pre class=
"platform-linux">
78 <b>tar xvf nacl_linux*.tgz
</b>
82 <pre class=
"platform-mac">
83 <b>tar xvf nacl_mac*.tgz
</b>
87 Windows: Do
<em>not
</em> use Cygwin unzip.
88 Instead, you can use the built-in Windows support.
90 right-click the .zip file
</code>
91 — for example,
<code>nacl_windows_0.1_8705859.zip
</code> —
92 and choose Extract All.
98 Test your version of Python.
101 <pre class=
"platform-all">
102 <b>python -V
</b> <em>#Note: That's an uppercase 'V'
</em>
106 The output should be something like
107 <code>Python
2.4.3</code>.
108 If your system can't find
<code>python
</code>
109 or the version isn't
2.4 or
2.5,
110 get the right version of Python
111 and make sure it's in your path.
113 <a href=
"building.html">Native Client build instructions
</a>.
117 <b>Do not use Cygwin's version of Python
</b>.
118 Instead, use the standard Python distribution.
120 <a href=
"building.html#setup-windows">Windows setup instructions
</a>.
127 <h2><a name=
"example-nacl" id=
"example-nacl"></a>Run an example as a Native Client app
</h2>
130 Now you'll learn how to run an example app in Native Client.
134 <b>Technical detail:
</b>
135 You might be wondering why we start you off with a command-line application,
136 rather than with the browser.
137 The reason is that when you create your own Native Client modules,
138 it's easier to get started
139 if you're working outside the browser.
145 In a terminal window, go to the earth demo's directory.
152 <pre class=
"platform-linux-mac">
153 <b>cd
</b><em>install_dir
</em><b>/nacl/googleclient/native_client/tests/earth
</b>
160 <pre class=
"platform-windows">
161 <b>cd
</b><em>install_dir
</em><b>\nacl\googleclient\native_client\tests\earth
</b>
167 Run the earth demo as a Native Client application.
168 The command is the same on all platforms:
172 <pre class=
"platform-all">
177 A window should appear
178 that contains a spinning, ray-traced globe.
179 The title of the window,
<b>NaCl Application
</b>,
180 indicates that you're running a Native Client module in a dedicated process.
183 <img src=
"images/NaClApp.jpg"
184 width=
"512" height=
"534"
185 alt=
"screenshot of the earth demo" />
186 <div class=
"caption">Figure: The earth demo running as a Native Client app (on Mac)
</span></div>
189 You can quit the earth demo by clicking the close (X) button
191 Or just wait; it quits automatically
192 after displaying
10000 frames.
196 [PENDING: Troubleshoot any likely problems.]
201 <h2><a name=
"plugin" id=
"plugin"> </a> Install and use the plug-in
</h2>
204 Now it's time to run some Native Client modules inside a browser.
205 To do so, you need to install the Native Client plug-in
206 and then load a page that refers to one or more Native Client modules.
212 Go to the
<code>native_client
</code> directory:
219 <pre class=
"platform-linux-mac">
220 <b>cd
</b><em>install_dir
</em><b>/nacl/googleclient/native_client
</b>
227 <pre class=
"platform-windows">
228 <b>cd
</b><em>install_dir
</em><b>\nacl\googleclient\native_client
</b>
235 both
<a href=
"http://nativeclient.googlecode.com/svn/trunk/nacl/googleclient/native_client/documentation/getting_started.html">online
</a>
236 and in your Native Client distribution
237 (
<em>install_dir
</em><b>/nacl/googleclient/native_client/documentation/getting_started.html
</b>).
238 The bookmarks will make it easier for you to get back to these instructions
239 after restarting your browser.
240 Consider printing out this page, as well,
241 or saving these instructions to a text or PDF file.
247 Exit Firefox if you're running it.
248 Also exit any other browsers that might have run a Native Client module.
249 The plug-in might not install correctly if Firefox is running
250 or if any other browser is running a Native Client module.
257 Answer
<b>y
</b> when asked whether you want to continue.
264 <pre class=
"platform-linux-mac">
265 <b>./scons --prebuilt firefox_install
</b>
267 Okay to continue? [y/n]
<b>y
</b>
272 <b>Technical detail:
</b>
273 The
<code>--prebuilt
</code> option
274 isn't strictly necessary,
275 but it makes the install go much more quickly.
276 Without it, SCons attempts to rebuild some of the Native Client binaries.
281 If you're using a
64-bit Linux system,
282 we recommend that you use a
32-bit browser.
283 For instructions, search for
284 [
<a href=
"http://www.google.com/search?&q=linux+32-bit+64-bit+browser">linux
32-bit
64-bit browser
</a>].
285 <em>If you're adventurous
</em>
286 and your modules don't use NPAPI,
287 then you might be able to instead use
288 <a href=
"http://www.google.com/url?sa=D&q=http%3A%2F%2Fgwenole.beauchesne.info/en/projects/nspluginwrapper">NSPluginWrapper
</a>
289 (version
1.1.2 or newer)
290 to make the Native Client plug-in work
292 Don't use NSPluginWrapper if your modules depend on NPAPI;
293 the performance impact of NSPluginWrapper's NPAPI forwarding can be huge.
300 <pre class=
"platform-windows">
301 <b>.\scons.bat --prebuilt firefox_install
</b>
303 Okay to continue? [y/n]
<b>y
</b>
310 you can't use SCons to install the plug-in on Vista.
311 Instead, you need to copy three files into
312 <code>C:\Program Files\Mozilla Firefox\plugins
</code>:
316 <li> <code><em>install_dir
</em>\nacl\googleclient\native_client\scons-out\opt-win\staging\
<b>npGoogleNaClPlugin.dll
</b></code> </li>
317 <li> <code><em>install_dir
</em>\nacl\googleclient\native_client\scons-out\opt-win\staging\
<b>SDL.dll
</b></code> </li>
318 <li> <code><em>install_dir
</em>\nacl\googleclient\native_client\scons-out\opt-win\staging\
<b>sel_ldr.exe
</b></code> </li>
322 [PENDING: Troubleshoot any likely problems.]
328 Look at the installer output
329 to make sure the installation was successful.
341 In Firefox, look at the following file:
345 <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>
350 That link works only if you're viewing this page
351 within the Native Client distribution, at
352 <code><em>install_dir
</em>/nacl/googleclient/native_client/documentation/getting_started.html
</code>.
357 Click the bottom-left link to go to the Mandelbrot viewer page.
358 This page has a Native Client implementation
359 of a Mandelbrot drawing.
360 You should see something like this:
364 <img src=
"images/mandelbrot.jpg"
365 width=
"587" height=
"536"
367 alt=
"screenshot of the Mandelbrot viewer demo" />
368 <div class=
"caption">Figure: The Mandelbrot viewer demo
</div>
373 You can click the Cycle Colors button to see an everchanging display of colors.
374 Press and hold the + button to zoom in.
375 Use the arrows on the large round button to
376 change which part of the Mandelbrot you can see.
384 For information about the other demos you can run in your browser, see
385 <a href=
"examples.html">Examples and Tests
</a>.
388 <h2><a name=
"make" id=
"make"> </a> Use make to compile and run standalone examples (Linux or Mac)
</h2>
391 In this section, you'll use GNU
<code>make
</code>
392 to compile and run the same example that you've already run.
393 First, you'll make a version that runs as a standalone application.
394 Next, you'll use
<code>make
</code>
395 to recompile the example and run it again as a Native Client app,
396 using the binaries that you created instead of prebuilt binaries.
397 Finally, you'll use
<code>make clean
</code>
398 and run the Native Client app again using the prebuilt binaries.
402 <b>Technical detail:
</b>
403 The standard build tool for Native Client is
405 You can compile our examples (on any platform) using SCons,
406 following the instructions in
407 <a href=
"building.html">Building Native Client
</a>.
408 The Makefiles exist so that
409 you can more easily use our examples
410 as templates for your own programs,
411 and so you can run our examples
412 as either Native Client or standalone applications (on Linux and Mac).
413 Running a module as a standalone application
414 can be handy when you're
415 <a href=
"debugging.html">debugging
</a>.
419 To perform the steps in this section,
420 your development environment needs to be set up
421 as described in the build instructions for your platform
—
422 <a href=
"building.html#setup-linux">Setup: Linux
</a> or
423 <a href=
"building.html#setup-mac">Setup: Mac OS X
</a>.
424 Native Client doesn't support
<code>make
</code> or standalone apps on Windows.
430 In a terminal window, go to the earth demo's directory:
433 <pre class=
"platform-linux-mac">
434 <b>cd
</b><em>install_dir
</em><b>/nacl/googleclient/native_client/tests/earth
</b>
440 Recompile the demo as a standalone application and run it.
443 <pre class=
"platform-linux-mac">
444 <b>make debug run
</b>
449 you should see a window with
451 This time, the title of the window is
<b>Standalone Application
</b>.
452 You'll also see the
<code>g++
</code> command
453 used to compile the demo as an app.
457 [PENDING: Troubleshoot any likely problems
— e.g. make missing
458 on a Mac that doesn't have Xcode installed.]
464 Recompile the demo as a Native Client module and run it again:
467 <pre class=
"platform-linux-mac">
468 <b>make release nacl run
</b>
472 Again you should see a spinning globe
473 with the title
<b>NaCl Application
</b>.
474 You'll also see the
<code>nacl-g++
</code> command
475 that compiles the demo
476 and the
<code>sel_ldr
</code> command
477 that runs it in the Native Client environment.
482 Remove the binaries you built,
483 and use the prebuilt binaries
484 to run the example again as a Native Client module.
487 <pre class=
"platform-linux-mac">
493 You can still run the example after running
<code>make clean
</code>
494 because the Makefile refers to binaries in the current directory.
495 The Python script, on the other hand,
497 that are in the
<code>scons-out/nacl/staging
</code> directory
498 (which is under
<code>nacl/googleclient/native_client
</code>).
499 The binaries under
<code>scons-out
</code>
500 are prebuilt for you,
501 but you can always rebuild using SCons,
503 <a href=
"building.html">Building Native Client
</a>.
509 <h2><a name=
"next" id=
"next"></a>What next?
</h2>
517 <a href=
"examples.html">examples and tests
</a>.
</li>
518 <li> <a href=
"building.html">Build Native Client
</a>
520 <li> Build Quake and XaoS for Native Client;
522 For instructions, see the
<code>README.nacl
</code> files under
523 <code>nacl/googleclient/native_client/tests/quake
</code> and
524 <code>nacl/googleclient/native_client/tests/xaos
</code>.
</li>
525 <li> Browse the
<a href=
"../README.html">documentation
</a>, including the
526 <a href=
"nacl_paper.pdf">Native Client paper
</a> [PDF].
</li>
527 <li> Browse the project site,
528 <a href=
"http://code.google.com/p/nativeclient">http://code.google.com/p/nativeclient
</a>,
530 <a href=
"http://code.google.com/p/nativeclient/wiki">wiki
</a>.
</li>
534 For even more fun, consider:
538 <li> Port existing open-source packages to run as
539 Native Client module components.
</li>
540 <li> Write new Native Client modules that use
541 Native Client's reduced system call interface, NPAPI, and SRPC
542 to communicate with the browser.
</li>
543 <li> Defeat the NaCl sandbox.
544 Can you create a NaCl module
545 that creates a file in the local file system
546 or otherwise directly executes a system call?
547 Exploits using
<code>sel_ldr
</code> from the command line
548 or from the browser plug-in are both of interest.
549 Don't use the
<code>-d
</code> debug flag
—
550 that would be too easy.
551 For more suggestions and details,
553 <a href=
"http://code.google.com/p/nativeclient/wiki/WhatToTest">WhatToTest
</a>.
558 And please participate in the Native Client community:
563 <a href=
"http://groups.google.com/group/native-client-discuss">discussion
565 <a href=
"http://groups.google.com/group/native-client-announce">announcement
567 <li> <a href=
"http://code.google.com/p/nativeclient/issues">File issues
</a>
568 about any Native Client problems you've noticed
569 or features you'd like.
</li>
574 <a href=
"http://code.google.com/policies.html#restrictions">noted
</a>,
575 the content of this page is licensed under a
576 <a href=
"http://www.google.com/url?sa=D&q=http%3A%2F%2Fcreativecommons.org/licenses/by/2.5/">Creative Commons
577 Attribution
2.5 license
</a>.