PHP-CPP Compilation Version

1

I'm having trouble with an extension that I'm compiling in PHP-CPP, because when compiling on my Mac, the local version of it is 20121212, but my Xampp is the 20131226 version, the problem is that in every version of php which have a compilation of their own, otherwise it does not work. How can I make a "universal" compilation?

    
asked by anonymous 09.11.2015 / 14:36

1 answer

0

Unfortunately you can not create a universal build, every version of php actually has different builds, this occurs in any software, not just php.

This problem occurs because of different types of architectures, for example:

  • Different processors
  • Different Operating Systems
  • Different compilers (mingw, msvc)
  • Different versions of compilers
  • Different versions of the same operating systems

The build of a specific version of compiled php is based on the "architecture that was compiled". As an example, Androids use Java as a language and "manager", this is because a program compiled in java does not run on the device directly, it runs on the "java virtual machine" and therefore with so many phones and tablets with different architectures can run a program on different processors like ARM and Intel, as each Android for each mobile architecture (with different processors) has its own version of Java that is compatible with the processor used in the device. p>

Returning to talk about compilation, the only way to have something universal in PHP is not to use extensions you create and to use .php that are not compiled but "interpreted" and will run in any compilation of PHP, even of different processors.

  

Note that many features of php5.3 do not work in 5.2, such as namespaces, just as php5.4 has features that are not supported by 5.3, we are talking about architecture rather than php versions.

Note that in addition to running on servers you can run php by terminal and if it is a like-unix environment or a "cgi port" you can create a file with any extension and apply the path of the php executable at the beginning of the code (I'm not sure, correct me if I've confused how to prepare the script):

#!/usr/local/bin/php-cgi
<?php

Or set the environment variable PATH to the path of the PHP executable.

If this is not an option, then you will actually have to compile the extension for each version of PHP, note this link :

  • php7:

    • VC14 x86 Non Thread Safe
    • VC14 x86 Thread Safe
    • VC14 x64 Non Thread Safe
    • VC14 x64 Thread Safe
  • php5.6:

    • VC11 x86 Non Thread Safe
    • VC11 x86 Thread Safe
    • VC11 x64 Non Thread Safe
    • VC11 x64 Thread Safe

Note that we have the terms VC11, x86, x64, NonThreadSafe and Thread Safe:

  • VC11 indicates that it was compiled in version 11 of VisualC ++
  • VC14 indicates that it was compiled in version 14 of VisualC ++
  • x86 indicates that it was compiled on a 32bit rendered just as x64 indicates that it was compiled on a 64bit rendered
  • ThreadSafe (TS) works with multi-threaded servers (Apache2 in Windows for example) and Non ThreadSafe (NTS) indicates if it was compiled.

    Thread Safety works by creating a local copy on each thread, so data will not collide with another thread.

    NTS does not have this and it is turned to FastCGI for example.

So you will have to do extensions much more than just compatible with the PHP version type. This build (20131226) is even meant to avoid problems.

The compiler environment for any type of software can be a little complicated, what you can do to make it easier is to distribute the source (many developers do this) and compile it directly on the machine that will be installed, creating a file % comp_de% (on windows you probably need to install a compiler) or a bash on linux (this is the good side of linux, usually it already comes with compiler).

An example is PHP itself, it is also distributed in source link (the .gz file), the binary versions in I think there are only distros that compile only after downloading the php machine, that is, they work with the source.)

In summary, the solutions are:

  • Use .php files instead of extensions
  • Compile the sources directly on the servers (if you can install .so or .dll on a server it is very likely that you can build something on it too.)
14.02.2016 / 05:03