Google V8编译

一、编译环境

最初是用centos7 镜像docker下,进行,最终总是有一个文件编译失败,并且未报明显的错误。
后转用
VMware + ubuntu-16.04.3-desktop-amd64

二、可以直接使用的lib库

如果不想去感受繁琐的编译过程,
可以尝试直接使用,附件中,我编译好的lib库
请查看附件:Googelv8(include+libs).zip

三、编译步骤

1、安装depot_tools

参考:https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up

  1. git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
  2. $ export PATH=/path/to/depot_tools:$PATH

2、下载V8代码

https://v8.dev/docs/source-code#using-git

  1. fetch v8

3、编译静态库

  1. Create a build configuration using the helper script:
  2. tools/dev/v8gen.py x64.release.sample
  3.  
  4. You can inspect and manually edit the build configuration by running:
  5. gn args out.gn/x64.release.sample
  6.  
  7. Build the static library on a Linux 64 system:
  8. ninja -C out.gn/x64.release.sample v8_monolith

4、编译sample代码

  1. g++ -I. -Iinclude samples/hello-world.cc -o hello_world -lv8_monolith -Lout.gn/x64.release.sample/obj/ -pthread -std=c++14 -DV8_COMPRESS_POINTERS

执行结果:

obamayang@obamayang-virtual-machine:~/workspace/v8$ ./hello_world 
  1. Hello, World!
  2. 3 + 4 = 7

四、一些编译帮助

1、 GLIBC_2.18 not found 问题

  1. strings /usr/lib64/libc.so.6 | grep GLIBC_2.1
  2.  
  3. wget http://mirrors.ustc.edu.cn/gnu/libc/glibc-2.18.tar.gz
  4. tar zxf glibc-2.18.tar.gz
  5. cd glibc-2.18/
  6. mkdir build
  7. cd build/
  8. ../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
  9. make -j4
  10. make install

2、 GLIBCXX_3.4.26’ not found问题

  1. 根据提示查看对应的路径
  2. strings /usr/lib64/libstdc++.so.6|grep GLIBCXX
  3. 发现缺少需要的3.4.26,3.4.20,3.4.21版本
  4.  
  5. 查看当前系统中所有libstdc++.so的位置,发现当前最新的动态库为libstdc++.so.6.0.27
  6. sudo find / -name "libstdc++.so*"
  7. 将新版本动态库复制到/usr/lib64中(注意自己libstdc++.so.6.0.xx的路径)
  8. cp /home/gcc-5.2.0/gcc-temp/stage1-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.27 /usr/lib64
  9. 删除老版本动态库(以下操作在/usr/lib64目录下)
  10. sudo rm -rf libstdc++.so.6
  11. 建立新链接(权限不够加上sudo)
  12. ln -s libstdc++.so.6.0.27 libstdc++.so.6
  13. 再次查看当前动态库版本
  14. strings /usr/lib64/libstdc++.so.6 | grep GLIBC
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值