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.本文介绍的 ...
随机推荐
- BS和CS对比
BS和CS对比 牛腩新闻发布系统已经开始了不短的时间了,CS的项目也算是接触了下,接下来对比下CS和BS CS和BS是什么? C/S结构即Client/Server(客户机/服务器)结构,是大家熟知的 ...
- [React] React Fundamentals: transferPropsTo
the transferPropsTo method lets you easily push properties into your components to easily customize ...
- iOS中的字符串扫描类NSScanner
新建一个Category,命名为UIColor+Hex,表示UIColor支持十六进制Hex颜色设置. UIColor+Hex.h文件, #import <UIKit/UIKit.h> # ...
- 从 setNeedsLayout 说起
本文从 setNeedsLayout 这个方法说起,分享与其相关的 UIKit 视图交互.使用场景等内容. UIKit 为 UIView 提供了这些方法来进行视图的更新与重绘: public func ...
- AutoInvoice in Oracle Apps R12
AutoInvoice in Oracle Apps R12 AutoInvoice is a powerful, flexible tool you can use to import and va ...
- Linux性能实时监测工具netdata安装配置
netdata:功能强大的实时性能检测工具,展示地址. github地址:https://github.com/firehol/netdata 本文介绍在CentOS 6.7下安装netdata 1. ...
- 处理 eclipse 导入报错 Invalid project description,问题
有时候在添加工程时,会出现如图所示的错误信息, ,提示显示将要添加的工程已经存在,但是在工作空间里却找不到,这个时候,要做就是, 在导入的时候选择General->Existing Projec ...
- 破解SQLYog30天试用方法
开始-运行-regedit ,进入注册表,在 \HEYK_CURRENT_USER\Software\{FCE28CE8-D8CE-4637-9BC7-93E4C0D407FA}下的InD保存着SQL ...
- 20160324 javaweb 之request
package com.dzq.servlet; import java.io.IOException; import javax.servlet.ServletException; import j ...
- tomcat启动
http://jingyan.baidu.com/article/c33e3f48a42352ea15cbb5d4.html