-
-
Save aozisik/a522e3b602daff6ae51f134aa949eec9 to your computer and use it in GitHub Desktop.
# This will retrieve v8 7.4.288.25 when installled | |
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/0a6171330678879285f2c566db9349da421d6f62/Formula/v8.rb | |
brew install v8.rb | |
brew list v8 | |
# You will see this: | |
# /usr/local/Cellar/v8/7.4.288.25/bin/d8 | |
# /usr/local/Cellar/v8/7.4.288.25/libexec/include/ (21 files) | |
# /usr/local/Cellar/v8/7.4.288.25/libexec/ (7 files) | |
mkdir -p /usr/local/Cellar/v8/7.4.288.25/libexec/lib | |
cp /usr/local/Cellar/v8/7.4.288.25/libexec/* /usr/local/Cellar/v8/7.4.288.25/libexec/lib | |
# Ignore the following errors, everything is fine: | |
# cp: /usr/local/Cellar/v8/7.4.288.25/libexec/include is a directory (not copied). | |
# cp: /usr/local/Cellar/v8/7.4.288.25/libexec/lib is a directory (not copied). | |
cd /tmp | |
git clone https://github.com/phpv8/v8js | |
cd v8js | |
git checkout php7 | |
phpize | |
./configure CXXFLAGS="-Wno-c++11-narrowing" --with-v8js="/usr/local/Cellar/v8/7.4.288.25/libexec" | |
make | |
make test | |
# Make sure that make test succeeds | |
make install | |
# Expected output: | |
# Installing shared extensions: /usr/local/Cellar/[email protected]/7.2.18/pecl/20170718/ | |
# Check if it's already working: | |
php -m | grep v8js | |
# No? It's not there? | |
# You may need to add v8js.so to your php.ini | |
# Locate your php.ini by doing: | |
php --ini | |
# Open the file and add: extension="v8js.so" | |
# Enjoy! | |
# Guys/gals... This took >4 hours to get right. | |
# | |
# Here are some troubleshooting checklist in case you're getting errors: | |
# | |
# - Make sure you have no other v8 libraries lying around your system. Get rid of those first! | |
# - Run apt-get update and upgrade before running this. Obviously... | |
# - I got v8js-2.0.0 working against 6.4.388.18. Never got it to work against v8-7.x... | |
# - Don't even try apt-get install libv8-7.2. Lost hours, couldn't get it to work... Just compile yourself... | |
# Install required dependencies | |
apt-get install build-essential curl git python libglib2.0-dev | |
cd /tmp | |
# Install depot_tools first (needed for source checkout) | |
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git | |
export PATH=`pwd`/depot_tools:"$PATH" | |
# Download v8 | |
fetch v8 | |
cd v8 | |
# I needed this to make it work with PHP 7.1 | |
git checkout 6.4.388.18 | |
gclient sync | |
# Setup GN | |
tools/dev/v8gen.py -vv x64.release -- is_component_build=true | |
# Build | |
ninja -C out.gn/x64.release/ | |
# Move libraries to necessary location | |
cp out.gn/x64.release/lib*.so /usr/lib/ | |
cp out.gn/x64.release/*_blob.bin /usr/lib | |
cp out.gn/x64.release/icudtl.dat /usr/lib | |
cp -R include/* /usr/include | |
cd out.gn/x64.release/obj | |
ar rcsDT libv8_libplatform.a v8_libplatform/*.o | |
# Are you getting v8 (library) not found error? Try this before pecl install: | |
apt-get install patchelf | |
for A in /usr/lib/*.so; do patchelf --set-rpath '$ORIGIN' $A;done | |
# Then let's pull v8js. | |
cd /tmp | |
git clone https://github.com/phpv8/v8js.git | |
cd v8js | |
# Checkout version 2.1.0 | |
git checkout 2.1.0 | |
phpize | |
# This flag is important! | |
./configure LDFLAGS="-lstdc++" --with-v8js=/usr | |
make clean | |
make | |
# Make sure that the tests pass... | |
make test | |
make install | |
# DON'T FORGET TO Add | |
# extension=v8js.so | |
# To your php.ini as needed. | |
# You can check if the module is there by doing php -m | grep v8js |
I'm facing issue to configuring v8js on mac and ubuntu 18
Can you help out to figure out this issue
checking how to allow c++11 narrowing... -Wno-c++11-narrowing
checking for libv8_libplatform... configure: error: could not find libv8_libplatform library
Just wanted to say thank you. After days of struggling with installing this shitload of a software, this is the first tutorial that finally worked. It even installed no problem on the M1 mac mini (using Rosetta2). You are my hero!
@KarimGeiger I'm on M1 mac mini as well stuck on
v8: Calling
cellar
in a bottle block is disabled! Usebrew style --fix
on the formula to update the style or usesha256
with acellar:
argument instead.
How do you manage to make it work? Thanks.
@jbrtsnts I didn't get that error message at all, so I don't know how to fix that. But I ran it using Rosetta 2, so prefixing every command with arch -x86_64
to run it on the x86 architecture, instead of ARM. Maybe that helps.
@KarimGeiger, I finally got it working. The formula is not working anymore, and only have to go with the latest version - 9.1.269.36 at the time of this comment. Thanks anyway for the quick response!
#For PHP 7.3
#use V8js version 2.1.1 instead of 2.1.0. and v8 version 7.5.288.30
git checkout 6.4.388.18 -> git checkout 7.5.288.30
git checkout 2.1.0 -> git checkout 2.1.1
#Tested on Ubuntu 18.04
Reference:
https://github.com/phpv8/v8js/releases/tag/2.1.1