2

got a little problem over here. I've compiled example Zephir plugin on my machine, which works fine on the workstation, but when I move it eg. to production server, I receive this weird php error:

PHP Startup: Unable to load dynamic library '/mod/utils.so' - /mod/utils.so: invalid ELF header in Unknown on line 0

The path is fine because when the file is not present in dir php throws file not found error.

Google told me nothing. Seems like no one ever encountered this kind of problem. Any ideas?

ben.arr
  • 21
  • 1
  • 2
  • Is your machine **identical** to the server? Have you tried compiling it on the production server? – MonkeyZeus Feb 23 '17 at 13:12
  • Diffrent machines, macOS on workstation and CentOS on production server – ben.arr Feb 24 '17 at 07:49
  • Cool, see the answer at http://stackoverflow.com/a/42417181/2191572 but ignore the parts about setting up an identical machine as the production environment. – MonkeyZeus Feb 24 '17 at 14:11

1 Answers1

2

"invalid ELF header" means your self compiled shared library is not compatible to the system on your production server. Here, it would be great to know the specifics / differences between your workstation and your production environment. This is because your lib has been compiled on your workstation for your workstation. Compiling that on the production server is a baaaaad idea, you should try to get a precompiled library and install it there, or in case you can't find one, compile the library on a identical environment like your production machine and install it afterwards on the production machine. Hope that helps.

Salic
  • 49
  • 5
  • Hello, thank you for your reply. I had it on my mind to compile on production server but it's just silly way of doing this. I work on iMac (osx sierra 10.12.3), on the production server I'm rocking CentOS. I've tried to run compiled PHP extension on several vagrant enviroments - but all failed with the same error – ben.arr Feb 24 '17 at 07:46
  • macOS uses an entirely different executable format, not to mention the ABI/syscall incompatibility. If you want to build on Mac and run on Linux, you're going to have to cross-compile. – Siguza Apr 03 '17 at 15:05