Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
smaqeelkazmi opened this issue Nov 3, 2018 · 24 comments

Comments

@smaqeelkazmi
Copy link

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

@stesie
Copy link
Member

stesie commented Nov 6, 2018

v8js versions >= 1.0.0 target PHP 7; if you really still want to go with PHP 5, the latest version you can use is 0.6.4 ... however this one doesn't work with recent V8 versions also.

(at least your build output shows api version 20121212, which is PHP 5.5, ... so if you actually want to use PHP 7, then your pecl/phpize calls were wrong)

@smaqeelkazmi
Copy link
Author

smaqeelkazmi commented Nov 7, 2018

Hi @stesie Thanks for your help

I'm using vagrant and I installed php7.1 and when I run php -v it results:

PHP 7.1.16-1+ubuntu14.04.1+deb.sury.org+1 (cli) (built: Apr  5 2018 10:49:09) (
NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.1.16-1+ubuntu14.04.1+deb.sury.org+1, Copyright (c) 1999
-2018, by Zend Technologies

And whe I run php -i | grep 'PHP API' it results:
PHP API => 20160303

And I'm trying to install latest version of phpv8js

Then why its throws me error that I'm using php5?

Sorry for asking question again, but I'm new to v8js.

Thanks
Cheers

@stesie
Copy link
Member

stesie commented Nov 7, 2018

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

@noogen
Copy link

noogen commented Nov 9, 2018

Echoing @stesie here, make sure you have libv8 installed in either /usr/ or /usr/local/ as it is setup to search for those path as seen configured in the build source here: https://github.com/phpv8/v8js/blob/php7/config.m4#L5

You can build libv8 from Google source (it takes like 2 hours to build) or install from here - https://launchpad.net/~pinepain/+archive/ubuntu/libv8 for Ubuntu (unfortunately, it does not have build for 14.04). For example on how to build for source, you can look at this: https://github.com/niiknow/docker-hostingbase/blob/master/FULL.md - use FROM trusty instead since I'm building for xenial and not trusty.

Once you have libv8, either:

  1. Manually run make configure and build v8js with --with-v8js=/path/to/your/v8/install
  2. or copy it to /usr/ or /usr/local for install using pecl

Example, I copied my installation from /opt/libv8-6.8 to /usr/local - https://github.com/niiknow/docker-hostingbase/blob/800d4b62c3ab19b0ed9614cc7f5b2dab8029d7af/Dockerfile#L22 before I run pecl install v8js

Tip/Summary, you can see if you have libv8 installed for use with pecl on your system by searching for it like so:

ls -la /usr/local/lib/libv8.so
ls -la /usr/lib/libv8.so

It must resolve at one of the two location.

@palfaro91
Copy link

using brew install v8 i don't get the libv8.so file. How do I get that file?

@noogen
Copy link

noogen commented May 21, 2019

Yeah, you would not have libv8.so on macOS from brew install. You may need to modify config.m4 in order to get it to compile but there are no instruction: #401

@noogen
Copy link

noogen commented May 21, 2019

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.

@palfaro91
Copy link

@noogen Pretty straight forward if you are familiar with these tools, not so much if you are following the readme.macOS.md file. After pulling out half my hair I ended up doing something like you suggested but just dragged and dropped the files to /usr/local/lib and /usr/local/lib/includes. I see that you could just point to their location using the --with-v8js flag. Nice to know.

Side note... on the readme, is the make native library=shared -j8 command similar to compiling v8 yourself with tools/dev/gm.py x64.release? I couldn't get the make command to run since a Makefile is not included.

@noogen
Copy link

noogen commented May 22, 2019

@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

@palfaro91
Copy link

@noogen I'm most likely going to have to set this up on a linux server so thanks for sharing that build script.

Hope this thread helps someone in the future.

@Jiri-Mihal
Copy link

@noogen I've tried your installation procedure, unfortunately I got this error.

➜ v8js git:(php7) make
/bin/sh /tmp/v8js/libtool --mode=compile g++ -Wno-c++11-narrowing -std=c++11 -I. -I/tmp/v8js -DPHP_ATOM_INC -I/tmp/v8js/include -I/tmp/v8js/main -I/tmp/v8js -I/usr/local/Cellar/php/7.3.6/include/php -I/usr/local/Cellar/php/7.3.6/include/php/main -I/usr/local/Cellar/php/7.3.6/include/php/TSRM -I/usr/local/Cellar/php/7.3.6/include/php/Zend -I/usr/local/Cellar/php/7.3.6/include/php/ext -I/usr/local/Cellar/php/7.3.6/include/php/ext/date/lib -I/usr/local/Cellar/v8/7.5.288.22/libexec/include -I/usr/local/Cellar/v8/7.5.288.22/libexec -DHAVE_CONFIG_H -Wno-c++11-narrowing -c /tmp/v8js/v8js_array_access.cc -o v8js_array_access.lo
mkdir .libs
g++ -Wno-c++11-narrowing -std=c++11 -I. -I/tmp/v8js -DPHP_ATOM_INC -I/tmp/v8js/include -I/tmp/v8js/main -I/tmp/v8js -I/usr/local/Cellar/php/7.3.6/include/php -I/usr/local/Cellar/php/7.3.6/include/php/main -I/usr/local/Cellar/php/7.3.6/include/php/TSRM -I/usr/local/Cellar/php/7.3.6/include/php/Zend -I/usr/local/Cellar/php/7.3.6/include/php/ext -I/usr/local/Cellar/php/7.3.6/include/php/ext/date/lib -I/usr/local/Cellar/v8/7.5.288.22/libexec/include -I/usr/local/Cellar/v8/7.5.288.22/libexec -DHAVE_CONFIG_H -Wno-c++11-narrowing -c /tmp/v8js/v8js_array_access.cc -fno-common -DPIC -o .libs/v8js_array_access.o
In file included from /tmp/v8js/v8js_array_access.cc:17:
In file included from ./php_v8js_macros.h:42:
In file included from /usr/local/Cellar/php/7.3.6/include/php/main/php.h:33:
In file included from /usr/local/Cellar/php/7.3.6/include/php/Zend/zend.h:335:
/usr/local/Cellar/php/7.3.6/include/php/Zend/zend_operators.h:113:18: warning:
'finite' is deprecated: first deprecated in macOS 10.9 - Use
isfinite((double)x) instead. [-Wdeprecated-declarations]
if (UNEXPECTED(!zend_finite(d)) || UNEXPECTED(zend_isnan(d))) {
^
/usr/local/Cellar/php/7.3.6/include/php/main/php_config.h:2653:24: note:
expanded from macro 'zend_finite'
#define zend_finite(a) finite(a)
^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/math.h:749:12: note:
'finite' has been explicitly marked deprecated here
extern int finite(double)
^
In file included from /tmp/v8js/v8js_array_access.cc:17:
In file included from ./php_v8js_macros.h:42:
In file included from /usr/local/Cellar/php/7.3.6/include/php/main/php.h:33:
In file included from /usr/local/Cellar/php/7.3.6/include/php/Zend/zend.h:335:
/usr/local/Cellar/php/7.3.6/include/php/Zend/zend_operators.h:124:18: warning:
'finite' is deprecated: first deprecated in macOS 10.9 - Use
isfinite((double)x) instead. [-Wdeprecated-declarations]
if (UNEXPECTED(!zend_finite(d)) || UNEXPECTED(zend_isnan(d))) {
^
/usr/local/Cellar/php/7.3.6/include/php/main/php_config.h:2653:24: note:
expanded from macro 'zend_finite'
#define zend_finite(a) finite(a)
^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/math.h:749:12: note:
'finite' has been explicitly marked deprecated here
extern int finite(double)
^
/tmp/v8js/v8js_array_access.cc:213:25: warning: 'GetEnteredContext' is
deprecated: Use GetEnteredOrMicrotaskContext().
[-Wdeprecated-declarations]
result->Set(isolate->GetEnteredContext(), i ++, ...
^
/usr/local/Cellar/v8/7.5.288.22/libexec/include/v8.h:7925:3: note:
'GetEnteredContext' has been explicitly marked deprecated here
V8_DEPRECATED("Use GetEnteredOrMicrotaskContext().",
^
/usr/local/Cellar/v8/7.5.288.22/libexec/include/v8config.h:311:29: note:
expanded from macro 'V8_DEPRECATED'
declarator attribute((deprecated(message)))
^
/tmp/v8js/v8js_array_access.cc:213:4: warning: ignoring return value of function
declared with 'warn_unused_result' attribute [-Wunused-result]
...result->Set(isolate->GetEnteredContext(), i ++, V8JS_INT(j));
^~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/v8js/v8js_array_access.cc:217:23: warning: 'GetEnteredContext' is
deprecated: Use GetEnteredOrMicrotaskContext().
[-Wdeprecated-declarations]
result->Set(isolate->GetEnteredContext(), V8JS_SYM("length"), V8...
^
/usr/local/Cellar/v8/7.5.288.22/libexec/include/v8.h:7925:3: note:
'GetEnteredContext' has been explicitly marked deprecated here
V8_DEPRECATED("Use GetEnteredOrMicrotaskContext().",
^
/usr/local/Cellar/v8/7.5.288.22/libexec/include/v8config.h:311:29: note:
expanded from macro 'V8_DEPRECATED'
declarator attribute((deprecated(message)))
^
/tmp/v8js/v8js_array_access.cc:217:2: warning: ignoring return value of function
declared with 'warn_unused_result' attribute [-Wunused-result]
...result->Set(isolate->GetEnteredContext(), V8JS_SYM("length"), V8JS_INT(i));
^~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/v8js/v8js_array_access.cc:248:36: warning: 'GetEnteredContext' is
deprecated: Use GetEnteredOrMicrotaskContext().
[-Wdeprecated-declarations]
if(!prototype->ToObject(isolate->GetEnteredContext()).To...
^
/usr/local/Cellar/v8/7.5.288.22/libexec/include/v8.h:7925:3: note:
'GetEnteredContext' has been explicitly marked deprecated here
V8_DEPRECATED("Use GetEnteredOrMicrotaskContext().",
^
/usr/local/Cellar/v8/7.5.288.22/libexec/include/v8config.h:311:29: note:
expanded from macro 'V8_DEPRECATED'
declarator attribute((deprecated(message)))
^
/tmp/v8js/v8js_array_access.cc:253:34: warning: 'GetEnteredContext' is
deprecated: Use GetEnteredOrMicrotaskContext().
[-Wdeprecated-declarations]
prototype_object->Get(isolate->GetEnteredContext(), prop...
^
/usr/local/Cellar/v8/7.5.288.22/libexec/include/v8.h:7925:3: note:
'GetEnteredContext' has been explicitly marked deprecated here
V8_DEPRECATED("Use GetEnteredOrMicrotaskContext().",
^
/usr/local/Cellar/v8/7.5.288.22/libexec/include/v8config.h:311:29: note:
expanded from macro 'V8_DEPRECATED'
declarator attribute((deprecated(message)))
^
/tmp/v8js/v8js_array_access.cc:253:3: warning: ignoring return value of function
declared with 'warn_unused_result' attribute [-Wunused-result]
...prototype_object->Get(isolate->GetEnteredContext(), property).ToLocal(&ret_value);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~
9 warnings generated.
/bin/sh /tmp/v8js/libtool --mode=compile g++ -Wno-c++11-narrowing -std=c++11 -I. -I/tmp/v8js -DPHP_ATOM_INC -I/tmp/v8js/include -I/tmp/v8js/main -I/tmp/v8js -I/usr/local/Cellar/php/7.3.6/include/php -I/usr/local/Cellar/php/7.3.6/include/php/main -I/usr/local/Cellar/php/7.3.6/include/php/TSRM -I/usr/local/Cellar/php/7.3.6/include/php/Zend -I/usr/local/Cellar/php/7.3.6/include/php/ext -I/usr/local/Cellar/php/7.3.6/include/php/ext/date/lib -I/usr/local/Cellar/v8/7.5.288.22/libexec/include -I/usr/local/Cellar/v8/7.5.288.22/libexec -DHAVE_CONFIG_H -Wno-c++11-narrowing -c /tmp/v8js/v8js_class.cc -o v8js_class.lo
g++ -Wno-c++11-narrowing -std=c++11 -I. -I/tmp/v8js -DPHP_ATOM_INC -I/tmp/v8js/include -I/tmp/v8js/main -I/tmp/v8js -I/usr/local/Cellar/php/7.3.6/include/php -I/usr/local/Cellar/php/7.3.6/include/php/main -I/usr/local/Cellar/php/7.3.6/include/php/TSRM -I/usr/local/Cellar/php/7.3.6/include/php/Zend -I/usr/local/Cellar/php/7.3.6/include/php/ext -I/usr/local/Cellar/php/7.3.6/include/php/ext/date/lib -I/usr/local/Cellar/v8/7.5.288.22/libexec/include -I/usr/local/Cellar/v8/7.5.288.22/libexec -DHAVE_CONFIG_H -Wno-c++11-narrowing -c /tmp/v8js/v8js_class.cc -fno-common -DPIC -o .libs/v8js_class.o
In file included from /tmp/v8js/v8js_class.cc:22:
In file included from ./php_v8js_macros.h:42:
In file included from /usr/local/Cellar/php/7.3.6/include/php/main/php.h:33:
In file included from /usr/local/Cellar/php/7.3.6/include/php/Zend/zend.h:335:
/usr/local/Cellar/php/7.3.6/include/php/Zend/zend_operators.h:113:18: warning:
'finite' is deprecated: first deprecated in macOS 10.9 - Use
isfinite((double)x) instead. [-Wdeprecated-declarations]
if (UNEXPECTED(!zend_finite(d)) || UNEXPECTED(zend_isnan(d))) {
^
/usr/local/Cellar/php/7.3.6/include/php/main/php_config.h:2653:24: note:
expanded from macro 'zend_finite'
#define zend_finite(a) finite(a)
^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/math.h:749:12: note:
'finite' has been explicitly marked deprecated here
extern int finite(double)
^
In file included from /tmp/v8js/v8js_class.cc:22:
In file included from ./php_v8js_macros.h:42:
In file included from /usr/local/Cellar/php/7.3.6/include/php/main/php.h:33:
In file included from /usr/local/Cellar/php/7.3.6/include/php/Zend/zend.h:335:
/usr/local/Cellar/php/7.3.6/include/php/Zend/zend_operators.h:124:18: warning:
'finite' is deprecated: first deprecated in macOS 10.9 - Use
isfinite((double)x) instead. [-Wdeprecated-declarations]
if (UNEXPECTED(!zend_finite(d)) || UNEXPECTED(zend_isnan(d))) {
^
/usr/local/Cellar/php/7.3.6/include/php/main/php_config.h:2653:24: note:
expanded from macro 'zend_finite'
#define zend_finite(a) finite(a)
^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/math.h:749:12: note:
'finite' has been explicitly marked deprecated here
extern int finite(double)
^
/tmp/v8js/v8js_class.cc:105:3: warning: ignoring return value of function
declared with 'warn_unused_result' attribute [-Wunused-result]
V8JS_GLOBAL(c->isolate)->Delete(v8_context, object_name_js);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~
./v8js_v8.h:37:32: note: expanded from macro 'V8JS_GLOBAL'
#define V8JS_GLOBAL(isolate) ((isolate)->GetCurrentCo...
^
/tmp/v8js/v8js_class.cc:530:4: warning: ignoring return value of function
declared with 'warn_unused_result' attribute [-Wunused-result]
...php_obj->DefineOwnProperty(context, key, zval_to_v8js(value, isolate), v8::ReadOnly);
^~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/v8js/v8js_class.cc:597:3: warning: ignoring return value of function
declared with 'warn_unused_result' attribute [-Wunused-result]
...php_obj->CreateDataProperty(context, method_name, ft->GetFunction(context).ToLocalChecked());
^~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/v8js/v8js_class.cc:462:2: warning: ignoring return value of function
declared with 'warn_unused_result' attribute [-Wunused-result]
context->Global()->Set(context, V8JS_SYM("global"), context->Global());
^~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/v8js/v8js_class.cc:508:2: warning: ignoring return value of function
declared with 'warn_unused_result' attribute [-Wunused-result]
...V8JS_GLOBAL(isolate)->DefineOwnProperty(context, object_name_js, php_obj, v8::ReadOnly);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./v8js_v8.h:37:32: note: expanded from macro 'V8JS_GLOBAL'
#define V8JS_GLOBAL(isolate) ((isolate)->GetCurrentCo...
^
/tmp/v8js/v8js_class.cc:1072:24: error: no viable conversion from
'v8::Extension *' to 'std::unique_ptr'
v8::RegisterExtension(jsext->extension);
^~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/include/c++/v1/memory:2397:28: note:
candidate constructor (the implicit copy constructor) not viable: no known
conversion from 'v8::Extension *' to 'const
std::__1::unique_ptr<v8::Extension,
std::__1::default_deletev8::Extension > &' for 1st argument
class _LIBCPP_TEMPLATE_VIS unique_ptr {
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/memory:2462:13: note:
candidate constructor template not viable: no known conversion from
'v8::Extension *' to 'std::nullptr_t' (aka 'nullptr_t') for 1st argument
constexpr unique_ptr(nullptr_t) noexcept : _ptr(pointer()) {}
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/memory:2490:3: note:
candidate constructor not viable: no known conversion from
'v8::Extension *' to 'std::__1::unique_ptr<v8::Extension,
std::__1::default_deletev8::Extension > &&' for 1st argument
unique_ptr(unique_ptr&& __u) noexcept
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/memory:2499:3: note:
candidate template ignored: could not match
'unique_ptr<type-parameter-0-0, type-parameter-0-1>' against
'v8::Extension *'
unique_ptr(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/memory:2505:3: note:
candidate template ignored: could not match 'auto_ptr'
against 'v8::Extension *'
unique_ptr(auto_ptr<_Up>&& __p,
^
/usr/local/Cellar/v8/7.5.288.22/libexec/include/v8.h:6500:60: note: passing
argument to parameter here
void V8_EXPORT RegisterExtension(std::unique_ptr);
^
/tmp/v8js/v8js_class.cc:1333:3: warning: ignoring return value of function
declared with 'warn_unused_result' attribute [-Wunused-result]
...jsobj->DefineOwnProperty(v8_context, key, zval_to_v8js(value, isolate), v8::ReadOnly);
^~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/v8js/v8js_class.cc:1357:2: warning: ignoring return value of function
declared with 'warn_unused_result' attribute [-Wunused-result]
jsobj->Delete(v8_context, key);
^~~~~~~~~~~~~ ~~~~~~~~~~~~~~~
9 warnings and 1 error generated.
make: *** [v8js_class.lo] Error 1

My setup is:

➜ ~ sw_vers
ProductName: Mac OS X
ProductVersion: 10.14.5
BuildVersion: 18F132

➜ ~ php -v
PHP 7.3.6 (cli) (built: May 31 2019 23:38:25) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.6, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.6, Copyright (c) 1999-2018, by Zend Technologies

➜ ~ pecl version
PEAR Version: 1.10.9
PHP Version: 7.3.6
Zend Engine Version: 3.3.6
Running on: Darwin Jiris-MacBook-Pro.local 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64

Any idea? Thank you!

@noogen
Copy link

noogen commented Jun 15, 2019

@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

@Jiri-Mihal
Copy link

Jiri-Mihal commented Jun 17, 2019

@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

@palfaro91
Copy link

Back again... @noogen @Jiri-Mihal
I just upgraded my MacBook and I'm now running Mojave 10.14.5 and I'm getting this error
PHP Warning: PHP Startup: Unable to load dynamic library '/tmp/v8js/modules/v8js.so' - dlopen(/tmp/v8js/modules/v8js.so, 0x0009): code signature in (/tmp/v8js/modules/v8js.so) not valid for use in process: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed. in Unknown on line 0
Before I follow the suggestions of uninstalling MacOs provided Apache and PHP and installing them through Brew, I wanted to know if you guys got it working without having to do that?

@noogen
Copy link

noogen commented Jun 18, 2019

@palfaro91 unfortunately, I've only use brew installation to run php-fpm and nginx on OSX so I'm not familiar with Apache setup on OSX. Though, a google search on your error show that it's something new in Mojave security that require library to be validated before it can be run on the default Apache. As a result, the standard recommendation is to uninstall MacOs provied Apache and PHP and installing them through Brew. ref: https://superuser.com/questions/1363013/apache-cant-load-php-unsigned-extensions-on-mac-os-mojave

@Jiri-Mihal
Copy link

@palfaro91 I use Nginx and PHP installed through Homebrew. I’ve never used Apache and PHP provided by macOS.

@kklon
Copy link

kklon commented Jun 19, 2019

@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

@noogen
Copy link

noogen commented Jun 19, 2019

@palfaro91 Due to changes in Mojave that required signing of *.so files, I'd suggest you remove and reinstall mojave bottles (especially), php, nginx, and v8js (need new bottles compilation). Again, you want to remove and install (not update)

Note, bottles also require you to have Mojave updated xcode (may need to re-accept license). You can see that v8 compile dependent on bottles https://github.com/Homebrew/homebrew-core/blob/0a6171330678879285f2c566db9349da421d6f62/Formula/v8.rb#L8

@kklon Your issue maybe different. It's not finding the v8js.so file so it maybe a php.ini things. If you also did an upgrade from High Seria to Mojave, then you want to also remove and install before trying to fix the php.ini

@stesie
Copy link
Member

stesie commented Jun 22, 2019

V8 7.5 should work since yesterday night. Please give it another try.

@noogen would you also want to file a PR with updates to README.MacOS.md file/instructions?

@y-nk
Copy link

y-nk commented Sep 5, 2019

@Jiri-Mihal you made my day !

@timothepearce
Copy link

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

@ice6
Copy link

ice6 commented Oct 25, 2019

@noogen

thank you so much :)

Follow your instruction, installed successfully.

I am on macOS Catalina.

php -v

PHP 7.3.11 (cli) (built: Oct 24 2019 11:29:00) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.11, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v2.7.0, Copyright (c) 2002-2019, by Derick Rethans

php --ri v8js

v8js

V8 Javascript Engine => enabled
V8 Engine Compiled Version => 7.4.288.25
V8 Engine Linked Version => 7.4.288.25
Version => 2.1.1

Directive => Local Value => Master Value
v8js.flags => no value => no value
v8js.icudtl_dat_path => no value => no value
v8js.use_date => 0 => 0
v8js.use_array_access => 0 => 0

@ice6
Copy link

ice6 commented Oct 25, 2019

@Jiri-Mihal thank you for your step by step instruction.

The key here is the right v8 version and proper v8 lib folder layout installed on the mac.

After that, use pecl install v8js may make the following step easier. :)

@JamesPJ
Copy link

JamesPJ commented Nov 27, 2019

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants