v8js: Error: could not find libv8_libplat form library - Installing v8JS PHP extension

I’m trying to install php v8js extension but stuck with an issue:

Here is the terminal data:

downloading v8js-2.0.0.tgz ...
Starting to download v8js-2.0.0.tgz (101,564 bytes)
.......................done: 101,564 bytes
28 source files, building
running: phpize
Configuring for:
PHP Api Version:         20121113
Zend Module Api No:      20121212
Zend Extension Api No:   220121212
Please provide the installation prefix of libv8 [autodetect] :
building in /tmp/pear/temp/pear-build-rootDcjzlc/v8js-2.0.0
running: /tmp/pear/temp/v8js/configure --with-php-config=/usr/bin/php-config --w
ith-v8js
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php5 -I/usr/include/php5/main -I/usr
/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/inclu
de/php5/ext/date/lib
checking for PHP extension directory... /usr/lib/php5/20121212
checking for PHP installed headers prefix... /usr/include/php5
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate
 PHP parsers.
checking for gawk... gawk
checking for V8 Javascript Engine... yes, shared
checking for V8 files in default path... found in /usr
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking how to run the C++ preprocessor... g++ -E
checking for C standard version... c++11
checking how to allow c++11 narrowing...
checking for libv8_libplatform... configure: error: could not find libv8_libplat
form library
ERROR: /tmp/pear/temp/v8js/configure --with-php-config=/usr/bin/php-config --wi
th-v8js' failed

Can you please help me.

Thanks in advance, cheers

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 24 (3 by maintainers)

Most upvoted comments

@noogen thank you a lot, it really helped. Finally I installed v8js on macOS Mojave with PHP 7.3.

Here are steps I followed, It could help to others:

Installing v8

  1. Be sure you don’t have any previous installation of v8 on your system.
  2. Download this v8 Homebrew formula (formula for v8 7.4.288.25): https://raw.githubusercontent.com/Homebrew/homebrew-core/0a6171330678879285f2c566db9349da421d6f62/Formula/v8.rb
  3. Install v8 using the downloaded formula: $ brew install v8.rb
  4. Fix directory structure inside installed v8: $ 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

Installing v8js extension

  1. Clone v8js to your local machine: $ git clone https://github.com/phpv8/v8js
  2. Build v8js from source: $ cd v8js $ phpize $ ./configure CXXFLAGS="-Wno-c++11-narrowing" --with-v8js="/usr/local/Cellar/v8/7.4.288.25/libexec" $ make $ make test $ make install

Enabling v8js in PHP

  1. Find your php.ini file: $ php --ini Configuration File (php.ini) Path: /usr/local/etc/php/7.3 Loaded Configuration File: /usr/local/etc/php/7.3/php.ini Scan for additional .ini files in: /usr/local/etc/php/7.3/conf.d Additional .ini files parsed: /usr/local/etc/php/7.3/conf.d/ext-opcache.ini
  2. Open your php.ini file: $ nano /usr/local/etc/php/7.3/php.ini
  3. Add this line to beginning and save ini file: extension=“v8js.so”
  4. Restart PHP: $ brew services restart php

@Jiri-Mihal that’s because the latest v8 (7.5.288.22) from homebrew deprecated a bunch of stuff. I tested latest v8 (7.5.288.22) on Mojave and got the same error as you.

Try uninstall your v8 brew uninstall v8, save this file (formula for v8 7.4.288.25) locally https://raw.githubusercontent.com/Homebrew/homebrew-core/0a6171330678879285f2c566db9349da421d6f62/Formula/v8.rb and run brew install v8.rb

Note, I’ve also successfully compile phpv8/v8js on latest macOS Mojave 10.14.5 and php 7.3.6 using v8 7.4.288.25

Instruction how I got it to work:

  1. Install v8 with: brew install v8
  2. Find out where it is installed
$ brew list v8
/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)
$ ls -la /usr/local/Cellar/v8/7.4.288.25/libexec
total 71392
drwxr-xr-x  10 tomn  staff       320 May 21 16:10 .
drwxr-xr-x  10 tomn  staff       320 May 21 15:36 ..
-rwxr-xr-x   1 tomn  staff    329556 May 21 15:36 d8
-rw-r--r--   1 tomn  staff  10326064 Apr 19 13:45 icudtl.dat
drwxr-xr-x  20 tomn  staff       640 Apr 19 13:45 include
-rwxr-xr-x   1 tomn  staff   3554732 May 21 15:36 libicui18n.dylib
-rwxr-xr-x   1 tomn  staff   2053864 May 21 15:36 libicuuc.dylib
-rwxr-xr-x   1 tomn  staff  19945340 May 21 15:36 libv8.dylib
-rwxr-xr-x   1 tomn  staff    193012 May 21 15:36 libv8_libbase.dylib
-rwxr-xr-x   1 tomn  staff    131744 May 21 15:36 libv8_libplatform.dylib
  1. Seem to be missing the lib dir so I mirror the linux directory structure like so: https://github.com/niiknow/docker-hostingbase/tree/master/rootfs/opt/libv8-7.4
$ 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
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).
$ ls -la /usr/local/Cellar/v8/7.4.288.25/libexec
total 71392
drwxr-xr-x  11 tomn  staff       352 May 21 16:11 .
drwxr-xr-x  10 tomn  staff       320 May 21 15:36 ..
-rwxr-xr-x   1 tomn  staff    329556 May 21 15:36 d8
-rw-r--r--   1 tomn  staff  10326064 Apr 19 13:45 icudtl.dat
drwxr-xr-x  20 tomn  staff       640 Apr 19 13:45 include
drwxr-xr-x   9 tomn  staff       288 May 21 16:12 lib
-rwxr-xr-x   1 tomn  staff   3554732 May 21 15:36 libicui18n.dylib
-rwxr-xr-x   1 tomn  staff   2053864 May 21 15:36 libicuuc.dylib
-rwxr-xr-x   1 tomn  staff  19945340 May 21 15:36 libv8.dylib
-rwxr-xr-x   1 tomn  staff    193012 May 21 15:36 libv8_libbase.dylib
-rwxr-xr-x   1 tomn  staff    131744 May 21 15:36 libv8_libplatform.dylib
  1. Now we’re ready to build. Below shows that I am using php7.2
$ git clone https://github.com/phpv8/v8js
$ cd v8js
$ git checkout php7
$ phpize
Configuring for:
PHP Api Version:         20170718
Zend Module Api No:      20170718
Zend Extension Api No:   320170718
$ php --version
PHP 7.2.18 (cli) (built: May  2 2019 13:05:02) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Xdebug v2.6.1, Copyright (c) 2002-2018, by Derick Rethans
    with Zend OPcache v7.2.18, Copyright (c) 1999-2018, by Zend Technologies
$ ./configure CXXFLAGS="-Wno-c++11-narrowing" --with-v8js="/usr/local/Cellar/v8/7.4.288.25/libexec"
$ make
...
$ make test
...
=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped    :    0
Exts tested     :   65
---------------------------------------------------------------------

Number of tests :  177               174
Tests skipped   :    3 (  1.7%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :    0 (  0.0%) (  0.0%)
Expected fail   :    0 (  0.0%) (  0.0%)
Tests passed    :  174 ( 98.3%) (100.0%)
---------------------------------------------------------------------
Time taken      :   22 seconds
=====================================================================
...
$ make install
Installing shared extensions:     /usr/local/Cellar/php@7.2/7.2.18/pecl/20170718/
$ ls -la /usr/local/Cellar/php@7.2/7.2.18/pecl/20170718/
total 1648
drwxr-xr-x  4 tomn  admin     128 May 21 16:05 .
drwxr-xr-x  3 tomn  admin      96 May  7 10:21 ..
-rwxr-xr-x  1 tomn  admin  551692 May 21 16:05 v8js.so
-rw-r--r--  1 tomn  admin  287020 Oct 25  2018 xdebug.so

Above are instructions from my MacBook Pro 15 (mid 2015), macOS High Seria 10.13.6, php 7.2, Homebrew 2.1.3

NOTE: I’ve historically compile v8js on linux. I never had a need to build v8 on macOS so I never tried. Once @palfaro91 hinted of v8 on macOS homebrew. Took me 5 minutes to figure and tested the instruction above. Pretty straight forward steps. I’m amazed there wasn’t any hiccup/trouble like it usually do when you try anything the first time.

@noogen thank you a lot, it really helped. Finally I installed v8js on macOS Mojave with PHP 7.3.

Here are steps I followed, It could help to others:

Installing v8

  1. Be sure you don’t have any previous installation of v8 on your system.
  2. Download this v8 Homebrew formula (formula for v8 7.4.288.25): https://raw.githubusercontent.com/Homebrew/homebrew-core/0a6171330678879285f2c566db9349da421d6f62/Formula/v8.rb
  3. Install v8 using the downloaded formula: $ brew install v8.rb
  4. Fix directory structure inside installed v8: $ 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

Installing v8js extension

  1. Clone v8js to your local machine: $ git clone https://github.com/phpv8/v8js
  2. Build v8js from source: $ cd v8js $ phpize $ ./configure CXXFLAGS="-Wno-c++11-narrowing" --with-v8js="/usr/local/Cellar/v8/7.4.288.25/libexec" $ make $ make test $ make install

Enabling v8js in PHP

  1. Find your php.ini file: $ php --ini Configuration File (php.ini) Path: /usr/local/etc/php/7.3 Loaded Configuration File: /usr/local/etc/php/7.3/php.ini Scan for additional .ini files in: /usr/local/etc/php/7.3/conf.d Additional .ini files parsed: /usr/local/etc/php/7.3/conf.d/ext-opcache.ini
  2. Open your php.ini file: $ nano /usr/local/etc/php/7.3/php.ini
  3. Add this line to beginning and save ini file: extension=“v8js.so”
  4. Restart PHP: $ brew services restart php

For me had to execute below commands as well

$ mkdir -p /usr/local/Cellar/v8/7.4.288.25/libexec/lib/include
$ cp /usr/local/Cellar/v8/7.4.288.25/libexec/include/* /usr/local/Cellar/v8/7.4.288.25/libexec/lib/include

@Jiri-Mihal you made my day !

@palfaro91 I’m having a similar issue, please comment if you find a solution. I’ll do the same, but i’m losing all hope after 3 days of bashing my head against a wall At the moment I’m stuck on

PHP Warning:  PHP Startup: Unable to load dynamic library 'v8js.so' (tried: /usr/local/lib/php/pecl/20180731/v8js.so (dlopen(/usr/local/lib/php/pecl/20180731/v8js.so, 9): Symbol not found: __zval_ptr_dtor
  Referenced from: /usr/local/lib/php/pecl/20180731/v8js.so
  Expected in: flat namespace
 in /usr/local/lib/php/pecl/20180731/v8js.so), /usr/local/lib/php/pecl/20180731/v8js.so.so (dlopen(/usr/local/lib/php/pecl/20180731/v8js.so.so, 9): image not found)) in Unknown on line 0

@Jiri-Mihal thank you so much, I was dying on my keyboard, watching V8js compilation errors…

@palfaro91 Actually, I meant to give kudos the author on having it working for macOS. It’s because I also had a tough time, in the past, trying to build on linux - especially with php 7.3; that I decided not to even try on my macOS. Since I’m familiar with docker, I just do all related work inside of docker.

Anyway, instruction is pretty old and it said to checkout version 3.32.6. If you look at older version of v8, you will find a Makefile example: https://github.com/v8/v8/tree/4.2-lkgr

In newer version, we use python tools to build, hence no more Makefile in master: https://github.com/v8/v8

You can look here if you’re interested in full build script (in linux) - https://github.com/niiknow/docker-hostingbase/blob/master/v8build/Dockerfile#L38

So far I can only guess what you’re doing, since you haven’t said much regarding your setup (apart from some package version numbers available from screen output).

So you seem to have some PHP 5.5 around (otherwise paths like /usr/lib/php5/20121212 wouldn’t be in the output). Since you seem to be on Ubuntu “trusty” (14.04 pops up multiple times), you likely have “php5-dev” installed – which you actually shouldn’t as you say you’d like to play around with php7.1

So there’s also the package version 7.1.16-1+ubuntu14.04.1+deb.sury.org+1 mentioned above, which seems to relate to Ondrejs packages. Since Ondrej wants to allow parallel installation of multiple PHP versions you need to be extra careful if you actually do so.

So to me it seems like php points to some PHP 7.1, your pecl script above to PHP 5.5, then you likely have some /usr/bin/phpize which is PHP 5.5 and some /usr/bin/phpize7.1 which is PHP 7.1, same for /usr/bin/php-config vs. /usr/bin/php-config7.1

Which version of V8 do you have installed? And particularly where to?

That all being said, you’ll likely want to continue like this (if you really need the version mess):

$ /usr/bin/phpize7.1
$ cd ...to.the.v8js.sources...
$ ./configure --with-php-config=/usr/bin/php-config7.1 --with-v8js=/path/to/your/v8/installation
$ make
$ make test

… you can leave off the path to libv8 if it is installed to /usr (i.e. /usr/include and /usr/lib)

Mind how the correct version of phpize and php-config are referenced