Google v8 - Hello world
OS:Window 7
1.下载v8 zip:https://github.com/v8/v8,解压zip,重命名v8-master文件夹为v8。
2.下载安装svn:http://tortoisesvn.net/downloads.html。安装后确认C:\Program Files\TortoiseSVN\bin被加到环境变量path
3.在v8根目录下Check out gyp
运行cmd:cd v8,切换到v8的根文件夹
运行cmd: svn co http://gyp.googlecode.com/svn/trunk build/gyp, gyp安装到v8/build/gyp
4.在v8根目录下Check out ICU
运行cmd:svn co https://src.chromium.org/chrome/trunk/deps/third_party/icu46 third_party/icu
5.在v8根目录下Check out cygwin
运行cmd:svn co http://src.chromium.org/svn/trunk/deps/third_party/cygwin@231940 third_party/cygwin
6.下载安装python 2.7.X:http://www.python.org/download/,安装后将python.exe的路径添加到path环境变量中
7.运行cmd:python build\gyp_v8 -Dtarget_arch=x64(注:按装python后要打开新的cmd窗口,并且当前目录切换到v8的根文件夹)
8.运行cmd:"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\dev
env.exe" /build release build\all.sln,或者用VS2010打开v8\build\all.sln, build. Build成功后在v8\build\Release\lib生成v8_base.x64.lib,v8_nosnapshot.x64.lib,v8_snapshot.lib,icui18n.lib,icuuc.lib。
9.用VS2010创建一个c++ Win32 Console Application,添加x64 build配置。在linker里面导入v8_base.x64.lib,v8_nosnapshot.x64.lib,v8_snapshot.lib,icui18n.lib,icuuc.lib,ws2_32.lib,winmm.lib。
10.Copy/Paste以下代码到main函数
#include <v8.h>
using namespace v8;
int main(int argc, char* argv[]) {
// Get the default Isolate created at startup.
Isolate* isolate = Isolate::GetCurrent();
// Create a stack-allocated handle scope.
HandleScope handle_scope(isolate);
// Create a new context.
Handle<Context> context = Context::New(isolate);
// Enter the context for compiling and running the hello world script.
Context::Scope context_scope(context);
// Create a string containing the JavaScript source code.
Handle<String> source = String::NewFromUtf8(isolate, "'Hello' + ', World!'");
// Compile the source code.
Handle<Script> script = Script::Compile(source);
// Run the script to get the result.
Handle<Value> result = script->Run();
// Convert the result to an UTF8 string and print it.
String::Utf8Value utf8(result);
printf("%s\n", *utf8);
return ;
}
11.Build,如果出现以下linker error,添加msvcprtd.lib;MSVCRTD.lib到linker/input/Ignore Specific Default Libriries
>LIBCMT.lib(memcpy.obj) : error LNK2005: memmove already defined in MSVCRTD.lib(MSVCR100D.dll)
Google v8 - Hello world的更多相关文章
- Google V8编程详解(五)JS调用C++
http://blog.csdn.net/feiyinzilgd/article/details/8453230 最近由于忙着解决个人单身的问题,时隔这么久才更新第五章. 上一章主要讲了Google ...
- Google V8编程详解附录
Google V8编程详工具函数 头文件:utils.h #ifndef UTILS_H_ #define UTILS_H_ #include "v8.h" #include &l ...
- Google V8编程详解(序)Cloud App
此系列文章转载于此http://blog.csdn.net/feiyinzilgd/article/details/8247723 应用程序发展到今天,应用程序的概念也在不断地发生着 ...
- Google V8扩展利器发布:v8-native-binding-generator
用C++扩展Google V8很简单,但是类比较多时还是很烦的.前段时间开发cantk-runtime-v8时,我写了一个代码产生器v8-native-binding-generator,让扩展Goo ...
- 用NAN简化Google V8 JS引擎的扩展
通过C++扩展Google V8 JS引擎的文章很多,Google V8 JS带的例子也容易明白.但是大部分文章都是Hello World型的,真正使用时发现处处是坑.扩展V8最经典的例子就是node ...
- 在Android上使用Google V8 JS 引擎
在cantk-runtime中直接使用的webview,通过JAVA扩展接口把Canvas的2d Context的API定向到JNI,通过OpenGL来图形加速,渲染速度大大提高.后来测试发现在大部分 ...
- google v8引擎常见问题
最近在项目中使用v8来进行扩展,下面简单说一下使用v8过程中遇到的一些问题. v8的多线程调用 最初调研v8的测试代码是单线程的,后来一个项目在多线程中使用,出现了一些问题,后来看到参考3中的才恍 ...
- Google V8 引擎 原理详解
V8 引擎概览 V8 引擎简介 Google V8 引擎使用 C++ 代码编写,实现了 ECMAScript 规范的第五版,可以运行在所有的主流 操作系统中,甚至可以运行在移动终端 ( 基于 ARM ...
- JavaScript 性能优化 --By Google V8 Team Manager
原文:https://developers.google.com/v8/?hl=zh-CN Be Prepared before writing code[9:35] Understand how V ...
- [原创]Windows下Google V8 javascript引擎编译
项目用到将v8嵌入到C++的情况,公司没时间研究,只有在家研究,编译过程一堆坑.记录一下. 网上百度的都是基于vs2010,或者早版本的v8编译,最新版本应该使用vs2013\vs2015.本文介绍的 ...
随机推荐
- os4开始CLLocationManager类中不支持locationServicesEnabled属性了
locationServicesEnabled改为类方法 //判断定位服务是否开启 if ([CLLocationManager locationServicesEnabled]) { }
- [转]Unity批量制作预制物体Prefab
http://www.u3dblog.com/?p=441 有时候场景中一大批物体都需要制作成预制物体,但是unity只能手动一个一个的创建,感觉非常的蹩脚,下面一个编辑器类的方法解决你的麻烦. st ...
- BS和CS对比
BS和CS对比 牛腩新闻发布系统已经开始了不短的时间了,CS的项目也算是接触了下,接下来对比下CS和BS CS和BS是什么? C/S结构即Client/Server(客户机/服务器)结构,是大家熟知的 ...
- webstrom热键[持续更新]
1.Ctrl+ Shift + A -- 为了加快寻找菜单命令或工具栏操作,你并不需要看菜单.只有按Ctrl+ Shift + A(说明|查找操作主菜单上),并开始输入动作的名称. . 2.Ctr ...
- 在chrome下安装Proxy SwitchySharp插件
https://chrome.google.com/webstore/detail/dpplabbmogkhghncfbfdeeokoefdjegm
- 【Heritrix基础教程之1】在Eclipse中配置Heritrix
一.新建项目并将Heritrix源代码导入 1.下载heritrix-1.14.4-src.zip和heritrix-1.14.4.zip两个压缩包,并解压,以后分别简称SRC包和ZIP包: 2.在E ...
- 存储过程为什么比sql效率高
对于存储过程为什么比sql效率高的原因有4点 第一就是使用存储过程允许组建式编成, 二是可以对程序进行编译,
- 移动终端学习1:css3 Media Queries简介
移动终端学习之1:css3 Media Queries简介 1.简介 这篇文章写的不错,我就不重复了,来个链接:http://www.w3cplus.com/content/css3-media-qu ...
- Yii框架页面运行流程
Yii框架页面运行流程 CComponent | CModel | CActiveRecord.CFormModel(所有模型的父类) | 表名.php(模型) | 入口文件------------- ...
- webrtc学习——mediaStream和MediaStreamTrack
This is an experimental technologyBecause this technology's specification has not stabilized, check ...