0

I have just started to experiment with Zephir over the weekend, and had managed to compile and run a hello world extension on the mac terminal. I have AMPPS installed, and am trying to install this extension on AMPPS. Not sure if my steps are correct, but if I copied the .so file over, I get this error from AMPPS:

Warning: PHP Startup: Unable to load dynamic library '/Applications/AMPPS/php-7.1/lib/extensions/ext/utils.so' - dlopen(/Applications/AMPPS/php-7.1/lib/extensions/ext/utils.so, 9): no suitable image found. Did find: /Applications/AMPPS/php-7.1/lib/extensions/ext/utils.so: mach-o, but wrong architecture /Applications/AMPPS/php-7.1/lib/extensions/ext/utils.so: stat() failed with errno=3 in Unknown on line 07.1.2

What is the correct way to install the compiled extensions on hosted servers in future?

apaderno
  • 28,547
  • 16
  • 75
  • 90
phantomhive
  • 145
  • 1
  • 1
  • 11
  • I use zephir, loving the syntax, but unless you know how to setup a ppa, and have builds for all distros inc windows and mac on all cpu architectures, you should perhaps just compile the extension again as part of your deployment. – Lawrence Cherone Feb 11 '18 at 02:53
  • 1
    To add to my previous comment, you don't need to install zephir on the target machine you only need the c code, `php7.0-dev libpcre3-dev gcc make re2c`, git clone the repo, enter into `./ext` dir and `./install`, then add it to php.ini – Lawrence Cherone Feb 11 '18 at 03:11
  • in other words, the .so file is not like, e.g. an .apk file that we can just upload onto different machines. rather, different machine needs its own compiled version? – phantomhive Feb 11 '18 at 03:20
  • That depends, apks also dont work on non arm processors off the bat directly on a pc, for the same reason. Its the same issue as a PHP extension compiled with VC11 won't work with php compiled with VC17, or one compiled on windows or mac wont work on linux. Follow something like, https://github.com/ice/framework who just use a composer post-install-cmd, which runs a script to run `./install` which is already sorted by zephir build, before you commit to github do `zephir fullclean` and your good to go. – Lawrence Cherone Feb 11 '18 at 03:42
  • I tried doing the above on an AWS server, and I get a series of errors like this: error: unknown type name 'zend_array' zend_array *symbol_table; any clues? – phantomhive Feb 12 '18 at 04:05
  • @LawrenceCherone I got it to work on an AWS server, not much luck on another shared server though, because I don't get permissions to compile on it. Nonetheless, your comments helped me greatly and I would gladly accept it as the answer. – phantomhive Feb 13 '18 at 03:56

1 Answers1

0

The ERROR was obvious : Unable to load dynamic library '/Applications/AMPPS/php-7.1/lib/extensions/ext/utils.so' . That may mean your .so lib was not found. Maybe you past your extension lib file into an incorrect path. So you can try to type php -i | grep extension in your terminal. And it will output your extension path like extension_dir => /usr/local/lib/php/extensions/no-debug-non-zts-20151012 => /usr/local/lib/php/extensions/no-debug-non-zts-20151012. Check your extension exist or not in this direction. BTW you can using command php -m to check how many extensions you have installed .

Vincent
  • 84
  • 6
  • the .so lib is there, as there's an option inside AMPPS to toggle it on (which automatically adds a line to the php.ini). For other versions where I didn't copy the .so file, the option does not appear. It seems the problem could be "wrong architecture". – phantomhive Feb 11 '18 at 02:53
  • Is your php source code (which you compiled your extension based on. ) version matched with your php runtime version(seems like it was php7.1 in your error message)? – Vincent Feb 11 '18 at 02:59