v8 编译 linux,使用g++在Mac平台编译v8项目

g++ -I ../v8/include main.cc -o out \

-Wl, ../v8/out/x64.release/libv8_base.a \

-Wl, ../v8/out/x64.release/libv8_libbase.a \

-Wl, ../v8/out/x64.release/libv8_external_snapshot.a \

-Wl, ../v8/out/x64.release/libv8_libplatform.a \

-Wl, ../v8/out/x64.release/libicui18n.a \

-Wl, ../v8/out/x64.release/libicudata.a \

-Wl, ../v8/out/x64.release/libicuuc.a \

-stdlib=libstdc++ \

-std=c++0x

上面参数中的 -stdlib=libstdc++ 表示最新版的mac使用的是llvm编译器,其默认的标准库是libc++,但v8依赖的是libstdc++。

最新的v8使用的c++11的特性,使用-std=c++0x 去除c++11的warning。

另,v8项目依赖的几个静态库文件是编译成功后在v8的out目录下生成的。

并且在执行的时候,文件依赖几个*.bin文件

下面是官方原文

Run the Example

Follow the steps below to run the example yourself:

Download the V8 source code and build V8 by following the download and build instructions.

This hello world example is compatible with the version 4.8. You can check out this branch with git checkout -b 4.8 -t branch-heads/4.8.

Build via make x64.release on a Linux x64 system to generate the correct binaries.

Copy the complete code from the previous section (the second code snippet), paste it into your favorite text editor, and save as hello_world.cpp in the V8 directory that was created during your V8 build.

Compile hello_world.cpp, linking to the static libraries created in the build process. For example, on 64bit Linux using the GNU compiler:

g++ -I. hello_world.cpp -o hello_world -Wl,--start-group out/x64.release/obj.target/{tools/gyp/libv8_{base,libbase,external_snapshot,libplatform},third_party/icu/libicu{uc,i18n,data}}.a -Wl,--end-group -lrt -ldl -pthread -std=c++0x

V8 requires its 'startup snapshot' to run. Copy the snapshot files to where your binary is stored: cp out/x64.release/*.bin .

Run the hello_world executable file at the command line. For example, on Linux, still in the V8 directory, type the following at the command line: ./hello_world

You will see Hello, World!.

打赏作者

bd284b8ac806a7d77eb139a9d0c2c561.pngxiaohei

微信支付

c9e2e61a6fa83345ae0cc3b638bd14c7.png

支付宝

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值