PHP-CPP Compilation Version

Asked

Viewed 50 times

1

I have a problem with an extension I am compiling in PHP-CPP, because when I compile on my Mac, the local version of it is 20121212, but my Xampp is version 20131226, the problem is that in each version of php that have a compilation of its own, otherwise it doesn’t work. How can I make a compilation "universal"?

1 answer

0


Unfortunately there is no way to create a universal compilation, each version of php actually has different builds, this occurs in any software, not only php.

This problem occurs because of different types of architectures, such as:

  • 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 php compiled is based on "architecture that has been compiled". For example, Androids use Java as a language and "manager", because a java compiled program does not run on the device directly, it runs on "java virtual machine" and so even with so many phones and tablets with different architectures can run a program on different processors like ARM and Intel, because each Android for each mobile architecture (with different processors) has its own version of Java which is compatible with the processor used on the device.

Going back to compilation, the only way to have something universal in PHP is not to use extensions created by you and go on to use .php which are not compiled, but rather "interpreted" and will run on any PHP build, even if from 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 and not versions of php.

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 php executable path 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 else set the environment variable PATH with the PHP executable path.

If this is not an option, then you will actually have to compile the extension for each version of PHP, note this http://windows.php.net/download:

  • 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 into a "32bit" processor just as x64 indicates that it was compiled into a "64bit" processor"
  • Threadsafe (TS) works with multi-thread servers (Apache2 on Windows for example) and Non Threadsafe (NTS) indicates if it has been compiled.

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

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

Then you will have to make extensions much more than just compatible with the PHP version type. This build (20131226) is really aimed at avoiding problems.

The build environment for any type of software can be a bit tricky even, what you can do to make it easy is to distribute the source (many developers do this) and compile it directly on the machine that will be installed, creating a file .bat (in windows is likely to need to install a compiler) or a bash on Linux (this is the good side of linux, usually already comes with compiler).

An example is PHP itself, it is distributed in source as well http://php.net/downloads.php (the archives. gz), the binary versions actually only exist for windows, who maintain the binary versions on linux systems are the repositories (I think there are distros that compile only after downloading php to the machine, ie work with the source).

In short, 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 compile something on it as well).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.