Google NACL 简介
Getting Started
This page tells you how to install Native Client and run demos, both in and outside of the browser. On Linux and Mac OS X, you can also recompile demos and run them as standalone applications.
Note: If you've already installed a previous version of the Native Client plug-in, you don't need to uninstall it. Just get the software and install the plug-in.
Contents
- Get the software
- Run an example as a Native Client app
- Install and use the plug-in
- Use make to compile and run standalone examples (Linux or Mac)
- What next?
Get the software
To run the examples as Native Client modules, you need Native Client, Python, and a browser — we recommend Firefox 3. If you want to develop your own Native Client modules, you'll also need platform-specific development tools such as Xcode on the Mac and Visual Studio on Windows, as described in the make section and the page Building Native Client.
Technical detail: Native Client doesn't itself require Python. We use Python for scripts such as those that build and run examples and that install the Native Client plug-in. We're working on simpler installers that don't require Python.
Here's how to install Native Client and Python.
Choose an installation directory (install_dir). Because Native Client is frequently updated, you might want a path that indicates the download or build date. For example:
/home/me/NaCl/Testing/2009-02-11(Linux)/Users/me/NaCl/Testing/2009-02-11(Mac)C:\NaCl\Testing\2009-02-11(Windows)
Important: Make sure the full path of install_dir contains no spaces.
Download the Native Client
.tgzor.zipfile for your platform.- Extract the files into install_dir. For example:
Linux:
tar xvf nacl_linux*.tgz
Mac:
tar xvf nacl_mac*.tgz
Windows:
Do not use Cygwin unzip. Instead, you can use the built-in Windows support or 7-Zip. For example: In the file manager, right-click the
nacl_windows_*.zip fileand choose Extract All. Test your version of Python.
python -V #Note: That's an uppercase 'V'
The output should be something like
Python 2.4.3. If your system can't findpythonor the version isn't 2.4 or 2.5, get the right version of Python and make sure it's in your path. For details, see the Native Client build instructions.Windows note: Do not use Cygwin's version of Python. Instead, use the standard Python distribution. For details, see the Windows setup instructions.
Run an example as a Native Client app
Now you'll learn how to run an example app in Native Client.
Technical detail: You might be wondering why we start you off with a command-line application, rather than with the browser. The reason is that when you create your own Native Client modules, it's easier to get started if you're working outside the browser.
In a terminal window, go to the earth demo's directory.
Linux or Mac:
cd install_dir/nacl/googleclient/native_client/tests/earth
Windows:
cd install_dir\nacl\googleclient\native_client\tests\earth
Run the earth demo as a Native Client application. The command is the same on all platforms:
python run.py
A window should appear that contains a spinning, ray-traced globe. The title of the window, NaCl Application, indicates that you're running a Native Client module in a dedicated process.

You can quit the earth demo by clicking the close (X) button in its window frame. Or just wait; it quits automatically after displaying 10000 frames.
Troubleshooting: If no window appears and you get a message starting with ERROR: Cannot find Native Client executable, you've probably downloaded the source-only distribution of Native Client. You can either download the distribution for your platform (Linux, Mac, or Windows) or build Native Client and its SDK.
Install and use the plug-in
Now it's time to run some Native Client modules inside a browser. To do so, you need to install the Native Client plug-in and then load a page that refers to one or more Native Client modules.
Go to the
native_clientdirectory:Linux or Mac:
cd install_dir/nacl/googleclient/native_client
Windows:
cd install_dir\nacl\googleclient\native_client
Bookmark this page, both online and in your Native Client distribution (
install_dir/nacl/googleclient/native_client/documentation/getting_started.html). The bookmarks will make it easier for you to get back to these instructions after restarting your browser. Consider printing out this page, as well, or saving these instructions to a text or PDF file.Exit Firefox if you're running it. Also exit any other browsers that might have run a Native Client module. The plug-in might not install correctly if Firefox is running or if any other browser is running a Native Client module.
Install the plug-in. Answer y when asked whether you want to continue.
Linux or Mac:
./scons --prebuilt firefox_install
...
Okay to continue? [y/n] y
...Technical detail: The
--prebuiltoption isn't strictly necessary, but it makes the install go much more quickly. Without it, SCons attempts to rebuild some of the Native Client binaries.Linux note: If you're using a 64-bit Linux system, we recommend that you use a 32-bit browser. For instructions, search for [linux 32-bit 64-bit browser]. If you're adventurous and your modules don't use NPAPI, then you might be able to instead use NSPluginWrapper (version 1.1.2 or newer) to make the Native Client plug-in work in a 64-bit browser. Don't use NSPluginWrapper if your modules depend on NPAPI; the performance impact of NSPluginWrapper's NPAPI forwarding can be huge.
Windows:
.\scons.bat --prebuilt firefox_install
...
Okay to continue? [y/n] y
...Vista note: If UAC is enabled, you can't use SCons to install the plug-in on Vista. Instead, you need to copy three files into
C:\Program Files\Mozilla Firefox\plugins:install_dir\nacl\googleclient\native_client\scons-out\opt-win\staging\npGoogleNaClPlugin.dllinstall_dir\nacl\googleclient\native_client\scons-out\opt-win\staging\SDL.dllinstall_dir\nacl\googleclient\native_client\scons-out\opt-win\staging\sel_ldr.exe
Look at the installer output to make sure the installation was successful.
Launch Firefox and return to this page.
Start up a local HTTP server, if one isn't already running on your computer. One way you can do this is by launching
tools/httpd.pyfrom thenative_clientdirectory.Note: Use Python 2.5 (not 2.4) to run
httpd.py, if possible. If you use 2.4 and reload a module that has been recompiled, you'll continue to see the old, cached version in your browser. The reason is that while 2.5 provides a Last-Modified header, 2.4 does not. If you must use 2.4, you can reload a changed module by either bypassing your browser's cache (see http://en.wikipedia.org/wiki/Bypass_your_cache) or emptying the cache.Linux:
cd install_dir/nacl/googleclient/native_client
/usr/bin/python2.5 tools/httpd.pyMac:
cd install_dir/nacl/googleclient/native_client
python tools/httpd.pyWindows:
cd install_dir\nacl\googleclient\native_client
python tools\httpd.pyTechnical detail: You need a local HTTP server because, for now, Native Client uses a whitelist that ensures that module URLs begin with
http://localhost. If you want to use other URLs, you can modify the Native Client whitelist, rebuild Native Client, and install the new build. For details, see the FAQ.In Firefox, visit the browser test page (
native_client/scons-out/nacl/staging/index.html), using a URL that begins withhttp://localhost. If you're usinghttpd.py, as shown in the previous step, then here's the URL you'll need:Click the bottom-left link to go to the Mandelbrot viewer page. This page has a Native Client implementation of a Mandelbrot drawing. You should see something like this:
Figure: The Mandelbrot viewer demoPlay with the demo. You can click the Cycle Colors button to see an everchanging display of colors. Press and hold the + button to zoom in. Use the arrows on the large round button to change which part of the Mandelbrot you can see.
For information about the other demos you can run in your browser, see Examples and Tests.
Use make to compile and run standalone examples (Linux or Mac)
In this section, you'll use GNU make to compile and run the same example that you've already run. First, you'll make a version that runs as a standalone application. Next, you'll use make to recompile the example and run it again as a Native Client app, using the binaries that you created instead of prebuilt binaries. Finally, you'll use make clean and run the Native Client app again using the prebuilt binaries.
Technical detail: The standard build tool for Native Client is SCons, not make. You can compile our examples (on any platform) using SCons, following the instructions in Building Native Client. The Makefiles exist so that you can more easily use our examples as templates for your own programs, and so you can run our examples as either Native Client or standalone applications (on Linux and Mac). Running a module as a standalone application can be handy when you're debugging.
To perform the steps in this section, your development environment needs to be set up as described in the build instructions for your platform — Setup: Linux or Setup: Mac OS X. Native Client doesn't support make or standalone apps on Windows.
In a terminal window, go to the earth demo's directory:
cd install_dir/nacl/googleclient/native_client/tests/earth
Recompile the demo as a standalone application and run it.
make debug run
Just like before, you should see a window with a spinning globe. This time, the title of the window is Standalone Application. You'll also see the
g++command used to compile the demo as an app.Recompile the demo as a Native Client module and run it again:
make release nacl run
Again you should see a spinning globe with the title NaCl Application. You'll also see the
nacl-g++command that compiles the demo and thesel_ldrcommand that runs it in the Native Client environment.Remove the binaries you built, and use the prebuilt binaries to run the example again as a Native Client module.
make clean
python run.pyYou can still run the example after running
make cleanbecause the Makefile refers to binaries in the current directory. The Python script, on the other hand, refers to binaries that are in thescons-out/nacl/stagingdirectory (which is undernacl/googleclient/native_client). The binaries underscons-outare prebuilt for you, but you can always rebuild using SCons, as described in Building Native Client.
What next?
Please try these:
- Run all the examples and tests.
- Build Native Client from scratch.
- Build Quake and XaoS for Native Client; run them. For instructions, see the
README.naclfiles undernacl/googleclient/native_client/tests/quakeandnacl/googleclient/native_client/tests/xaos. - Browse the documentation, including the Native Client paper [PDF].
- Browse the project site, http://code.google.com/p/nativeclient, including the wiki.
For even more fun, consider:
- Port existing open-source packages to run as Native Client module components.
- Write new Native Client modules that use Native Client's reduced system call interface, NPAPI, and SRPC to communicate with the browser.
- Defeat the NaCl sandbox. Can you create a NaCl module that creates a file in the local file system or otherwise directly executes a system call? Exploits using
sel_ldrfrom the command line or from the browser plug-in are both of interest. Don't use the-ddebug flag — that would be too easy. For more suggestions and details, see the wiki page WhatToTest.
And please participate in the Native Client community:
- Join the discussion group and the announcement group.
- File issues about any Native Client problems you've noticed or features you'd like.
Except as otherwise noted, the content of this page is licensed under a Creative Commons Attribution 2.5 license.
Google NACL 简介的更多相关文章
- 怎样用Google APIs和Google的应用系统进行集成(1)----Google APIs简介
Google的应用系统提供了非常多的应用,比方 Google广告.Google 任务,Google 日历.Google blogger,Google Plus,Google 地图等等非常的多的应用,请 ...
- Google Bazel简介
最近跑一个代码,需要用到Bazel. Bazel
- Google Map API V3开发(1)
Google Map API V3开发(1) Google Map API V3开发(2) Google Map API V3开发(3) Google Map API V3开发(4) Google M ...
- Google改变生活
前言 前天,在图书馆,无意之中,发现这本书,特写博客来与各位前来下榻本园的博友们,分享和学习! 本博文的主要内容有: 参考此书.感谢韩梅编者,出于此,我写本博文为了方便日后自己的查阅使用和来我园的共 ...
- 高效率使用google
Google良好的搜索和易用性已经得到了广大网友的欢迎,但是除了我们经常使用的Google网站.图像和新闻搜索之外,它还有很多其他搜索功能和搜索技巧.如果我们也能充分利用,必将带来更大的便利.这里我介 ...
- 两步验证杀手锏:Java 接入 Google 身份验证器实战
两步验证 大家应该对两步验证都熟悉吧?如苹果有自带的两步验证策略,防止用户账号密码被盗而锁定手机进行敲诈,这种例子屡见不鲜,所以苹果都建议大家开启两步验证的. Google 的身份验证器一般也是用于登 ...
- 《Google Glass开发指南》
<Google Glass开发指南> 基本信息 作者: BestApp工作室 丛书名: 图灵原创 出版社:人民邮电出版社 ISBN:9787115349477 上架时间:2014-3-19 ...
- 全球级的分布式数据库 Google Spanner原理
开发四年只会写业务代码,分布式高并发都不会还做程序员?->>> Google Spanner简介 Spanner 是Google的全球级的分布式数据库 (Globally-Di ...
- AI - AutoKeras - 简介
前言 在数据集上训练神经网络时,主要有两个目标: 定义符合数据集特性的神经网络架构. 在许多试验中对一组超参数进行调优,从而使得模型具有较高的准确率并且能够泛化至训练集和测试集之外的数据. 针对不同的 ...
随机推荐
- JQuery ----文档处理
1.append(content|fn) 概述 向每个匹配的元素内部追加内容. 这个操作与对指定的元素执行appendChild方法,将它们添加到文档中的情况类似. 2.appendTo(conten ...
- .NET开源工作流RoadFlow-流程设计-流程步骤设置-数据设置
数据设置是控制在流程处理过程中,当前步骤的数据显示与编辑状态,控制当前步骤哪些字段为只读,隐藏或可编辑.需要配合表单设计器使用.
- C++ 的全局构造与析构函数
我们知道一般的C/C++ 的程序是从main函数开始的,然后在main函数结束后程序结束.但是不然,在main函数开始执行前,已经有其他的指令被执行了. 为了程序的顺利执行,首先要初始化执行环境,比如 ...
- hdu 2680 Choose the best route
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2680 Choose the best route Description One day , Kiki ...
- jquery 源码学习(一)
从上边的注释看,jQuery的源码结构相当清晰.条理,不像代码那般晦涩和让人纠结 1. 总体架构 1.1 自调用匿名函数 self-invoking anonymous function 打开jQ ...
- ubuntu 安装cloudera hadoop
参考:http://www.aboutyun.com/thread-8921-1-1.html auto wlan0iface wlan0 inet staticaddress 10.32.37.12 ...
- 三星Galaxy Note 10.1 N8010 最后的救赎 Andorid 5.0.2 ROM
上市日期为2012年的三星Galaxy Note N8010 10.1采用10.1英寸TFT屏幕,分辨率为1280×800,支持10点触控,支持S pen手写笔功能.,拥有一颗1.4GHz Exyno ...
- RHEL 6.4中解决xx用户不在sudoers列表,此事将被报告的问题
1.使用sudo service iptables status命令时报告没有权限: [tansheng@localhost ~]$ sudo service iptables status [sud ...
- Node.js 学习(六)Node.js EventEmitter
Node.js 所有的异步 I/O 操作在完成时都会发送一个事件到事件队列. Node.js里面的许多对象都会分发事件:一个net.Server对象会在每次有新连接时分发一个事件, 一个fs.read ...
- Codeforces Round #349 (Div. 1) B. World Tour 最短路+暴力枚举
题目链接: http://www.codeforces.com/contest/666/problem/B 题意: 给你n个城市,m条单向边,求通过最短路径访问四个不同的点能获得的最大距离,答案输出一 ...