chrome native client小试牛刀
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); }
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
atom-shell: GitHub 开源的跨平台桌面应用框架(基于 Node.js 和 HTML 5) atom-shell是 GitHub 随 Atom 一起开源的跨操作系统(Windows,Linux,MacOS X)的利用 Web 技术(Node.js、JavaScript、HTML 5)开发桌面应用的框架。Atom即构建在 atom-shell 之上。
相关文章
- Chrome断点调试
- 谷歌打开微信定位服务器地址,使用Chrome修改user agent模拟微信内置浏览器
- 视频文件无效怎么修复_google chrome怎么设置兼容模式
- Chrome 开发者工具里根据关键字搜索,结果列表里的 JavaScript 文件名后面跟的 ‘eval‘ 是什么含义
- 写一个chrome插件到底有多难?
- 30个Chrome 灵魂插件!
- Chrome调试
- 从0开始入门Chrome Ext安全(三) -- 你所未知的角落 - Chrome Ext安全
- chrome 常用快捷键
- XX-Net使用:使用Chrome浏览器(二)详解程序员
- [下载] 谷歌浏览器Google Chrome v80正式版发布 带来诸多新功能和改进
- Google将在Chrome 40中移除SSL 3.0
- Google Chrome/Chromium 将不支持旧版本的Linux内核
- 谷歌几乎完全开源 Chrome For Android
- Google Chrome vs 微软Edge:哪款浏览器更快?
- MacOS Chrome:畅享高效浏览体验(macos chrome)
- js兼容多浏览器的回车和鼠标焦点事件代码(IE6/7/8,firefox,chrome)
- javascript判断chrome浏览器的方法