v8引擎helloworld
来源:互联网 发布:泰格软件使用教程 编辑:程序博客网 时间:2024/05/26 02:54
分享请标明来自: https://www.css3.io/v8_helloworld.html
背景
v8引擎跟前端所用javascript语言密切相关。学习它有助于以后对node,以及浏览器内核学习。
官方地址:https://developers.google.com/v8/
目标
从编译源码到运行helloworld
实战记录
1.安装 depot_tools
这个工具是用来管理v8源码以及依赖的,把它的角色理解为包管理。因为v8的依赖很多,可能采用不同的源码版本管理方式,以及其它比较复杂的情况。很难用一些简单的现成的项目来管理依赖。于是乎就搞了这个。(纯属个人的理解)
官方地址:http://dev.chromium.org/developers/how-tos/install-depot-tools
2.下载v8源码
1.gclient (非必须,为了更新gclient工具本身)2.fetch v8也可这样:1.mkdir v82.cd v83.gclient config https://chromium.googlesource.com/v8/v84.gclient sync
3.源码build
make native -j4 library=shared snapshot=off说明:这里编译为了动态链接库。这个点比较重要。在mac上会得到一个libv8.dylib文件,linux是libv8.so.-j4 表示用4个线程来编译library=shared 表示编译成动态链接库snapshot=off 会编译快一点更多参数请参照:https://github.com/v8/v8/wiki/Building%20with%20Gyp
参考:
include 文件目录结构如下:
├── libplatform│ └── libplatform.h├── v8-debug.h├── v8-experimental.h├── v8-platform.h├── v8-profiler.h├── v8-testing.h├── v8-util.h├── v8-version.h├── v8.h└── v8config.h
build 后native目录结构如下:
├── cctest├── d8├── generate-bytecode-expectations├── hello-world├── icudtl.dat├── libfuzzer_support.a├── libgmock.a├── libgtest.a├── libicui18n.dylib├── libicuuc.dylib├── libjson_fuzzer_lib.a├── libparser_fuzzer_lib.a├── libregexp_fuzzer_lib.a├── libv8.dylib├── libv8_base.a├── libv8_libbase.a├── libv8_libplatform.a├── libv8_libsampler.a├── libv8_nosnapshot.a├── libwasm_asmjs_fuzzer_lib.a├── libwasm_fuzzer_lib.a├── obj├── obj.host├── obj.target├── process├── unittests├── v8_shell├── v8_simple_json_fuzzer├── v8_simple_parser_fuzzer├── v8_simple_regexp_fuzzer├── v8_simple_wasm_asmjs_fuzzer└── v8_simple_wasm_fuzzer
4.编译helloworld
g++ -I./include hello_world.cpp -o helloworld -L./out/native -lv8 -lv8_libbase -lv8_libplatform说明:-I./include 指明头文件所在目录-L./out/native 指明链接库根目录-lv8 指明libv8.dylib v8动态链接库-lv8_libbase 指明libv8_libbase.a-lv8_libplatform 指明libv8_libplatform.a
注意:
1、libv8_libplatform.a 这个静态库在新版本的v8使用时是必须要的
这个库依赖libv8_libbase.a,所以二者都必须有。很多时候死在了这两个库没加上。
2、头文件include/libplatform/libplatform.h 里面代码依赖v8-platform.h需要改为正确的路径
#include "v8-platform.h" 改为:#include "../v8-platform.h"
0 0
- v8引擎helloworld
- v8引擎
- JavaScript V8引擎
- V8 引擎使用心得
- javascript 引擎 V8 介绍
- 编译v8引擎
- javascript 引擎 V8 介绍
- JavaScript V8引擎
- V8引擎嵌入指南
- 编译v8引擎
- V8 javascript 引擎
- V8引擎之Binding
- V8引擎分析
- v8引擎学习
- 编译v8引擎
- V8 引擎使用心得
- V8 javascript 引擎
- Javascript V8 引擎
- Design Pattern(6)-Adapter Pattern
- C#中怎么判断一个数组中是否存在某个数组值
- Java基础学习之画板2
- RecyclerView的用法
- Picasso
- v8引擎helloworld
- MD5加密
- 《Objective-C编程全解》 读书笔记 第十七章 实例:简单图像视图
- Android 代码混淆
- HTTP in iOS你看我就够
- Burpsuite与sqlmap结合进行sql注入渗透测试
- POJ
- 深入解析MySQL分区(Partition)功能
- 网络流问题:最大流及其算法