一、环境准备
1、安装native client sdk
下载地址: http://commondatastorage.googleapis.com/nativeclient-mirror/nacl/nacl_sdk/naclsdk_win.exe
下载后安装在C:\native_client_sdk_0_5_1052
本次试验的两个关键目录project_templates,examples.其中project_templates包含一个模板代码生成,examples中包含示例代码。
2、安装python
下载地址:http://www.python.org/ftp/python/2.7.2/python-2.7.2.msi
下载后安装到C:\Python27,在系统环境变量中的Path最后加上;C:\Python27
3、在chrome中启用native client
在chrome浏览器中地址栏输入about:flags 找到native client点击启动,重启浏览器;然后在浏览器地址栏输入about:plugins找到native client点击启动,无须重启浏览器
二、查看示例
进入C:\native_client_sdk_0_5_1052\examples,双击httpd.py,启动python的web server。
在chrome地址栏输入http://localhost:5103/index.html,可查看自带示例。
三、开发示例
1、创建工程
进入控制台:
>cd C:\native_client_sdk_0_5_1052\project_templates
> init_project.py -n helloworld -d ../examples (-n 名称 -d目录)
这时在examples文件下多了一个helloworld目录。改目录有:
helloworld.cc c++代码
helloworld.html 网页代码
scons.bat 编译C++
2、修改代码
打开helloworld.html,新增
function moduleDidLoad() {
HelloTutorialModule = document.getElementById('hello_tutorial');
HelloTutorialModule.addEventListener('message', handleMessage, false);
updateStatus('SUCCESS');
//Send a message to the NaCl module.
HelloTutorialModule.postMessage('hello');
}
HelloTutorialModule.postMessage('hello');将hello字符串提交给c++端处理
打开helloworld.cc
在#include之后添加
namespace {
// The expected string sent by the browser.
const char* const kHelloString = "hello";
// The string sent back to the browser upon receipt of a message
// containing "hello".
const char* const kReplyString = "hello from NaCl";
} // namespace
找到
// TODO(sdk_user): 1. Make this function handle the incoming message.
替换成
if (!var_message.is_string())
return;
std::string message = var_message.AsString();
pp::Var var_reply;
if (message == kHelloString) {
var_reply = pp::Var(kReplyString);
PostMessage(var_reply);
}
编译C++的native client module ,双击helloworld目录底下的scons.bat文件。
编译完成后,生成:
hello_tutorial_x86_32.nexe
hello_tutorial_x86_32_dbg.nexe
hello_tutorial_x86_64.nexe
hello_tutorial_x86_64_dbg.nexe
进入C:\native_client_sdk_0_5_1052\examples
双击httpd.py
在chrome浏览器中输入地址:http://localhost:5103/helloworld/helloworld.html
得到从native client module返回的hello from NaCl
分享到:
相关推荐
谷歌的chrome native client是一种为浏览器编译运行native代码开源的技术,出于维护系统的安全便捷的目的,创造出人们所期望的web应用程序.native技术远远超出了javascript的web编程范畴,使得开发者使用他们自己喜欢的...
Chrome Extension 简单几步学会chrome扩展,学会了chrome extension 冲刺告别各种ide vs code带你飞起。
gameboy:针对Linux,OSX,asm.jsEmscripten和Chrome Native Client(NaCl)的Gameboy模拟器
本《适用于 Chrome 的 VMware Horizon Client 用户指南》文档介绍如何通过适用于 Chrome 的 VMware Horizon® Client™ 连接并使用远程桌面和已发布的应用程序。 Horizon Client 可充当客户端设备与远程桌面和已发布...
JavaScript Web Workers,Chrome Native Client(NaCl)和WebGL着色器的算法艺术作品 这位前 -Kollege ,谁现在是一名数学教授,在1995年已决定一个很好的算法,通过色彩空间转换的图形是让人联想到现代艺术点菜...
本《适用于 Chrome 的 VMware Horizon Client 安装和设置指南》文档提供了有关在 Chromebook 上安 装、配置和使用适用于 Chrome 的 VMware Horizon® Client™ 的信息。 本文档中的信息专门为已熟练掌握虚拟机技术和...
压缩包里包含了Windows,Mac,Linux的安装包,下载后选择自己的系统解压即可,Chrome用插件调用IDM所必备的一个补丁,为大家提供一个方便的下载途径,免受外网限速的折磨。
chrome cef client win可执行文件
Google Chrome本机消息传递C ++应用程序和Google Chrome浏览器之间使用JSON进行数据通信。 来自示例代码Google Chrome网上应用店: :
实现chrome获取MAC地址的扩展。 通过c++获取MAC地址,然后通过Chrome native message 技术调用C++程序,在javascript中获取MAC地址
Chrome原生消息 作为本机应用程序与 Chromium 或 Google Chrome 扩展程序通信。 有关我的意思的更多信息...( let * ((buffer (chromium-native-messaging:read-from-ext *standard-input* )) (json-object (jsown:pa
Web Api调试工具 Chrome插件Restlet-Client-REST-API-Testing
汉化版本Internet Download Manager在Chrome浏览器中无法使用扩展程序插件补丁
网页和本机应用程序可以使用与其他消息传递API相似的API通过Accops Native Client扩展来交换消息。 支持此功能的本机应用程序必须注册知道如何与扩展进行通信的本机消息传递主机。 Chrome会在一个单独的过程中启动...
它使用 Google Chrome 中的 Google [Native Client] ( ) 运行时。 它目前在运行。 要使用 Osoasso,您必须为所有 Web 应用程序启用 Native Client,即使是那些不是从 Chrome 网上应用店安装的应用程序。 为此,请...
chrome插件解压版,打开浏览器开发者模式使用,新版microsoft edge也可以使用,也需要打开开发者模式
允许使用Chrome Native Messaging协议与Chrome扩展程序轻松通信。 安装 在上获取它: PM> Install-Package Lyre 用法 var host = new NativeMessagingHost(); try { while (true) { var response = await host....
Rest Client Chrome 插件,调试工具
chrome设置编码插件: chrome://extensions/