I've been trying to build and link libphp5.so using the --enable-embed configure option, on OSX. This doesn't complete successfully, failing primarily because of object files not being found during the linking stage.
There are reports that the --enable-embed option has been broken on OSX for a long time.
Has anybody had any success doing this, linking and embedding the Zend Engine functions into a C/C++ app?
I finally managed to do this after lots of failed attempts. Here is a configure string that will build the libphp5.a library on OSX for PHP 5.3.6:
./configure --enable-embed=static --disable-libxml --disable-dom --disable-simplexml --disable-xml --disable-xmlreader --disable-xmlwriter --without-pear --without-iconv
Then, when linking to C/C++ code, you need to add libresolv to prevent link errors relating to DNS functions in the Zend Engine. For example:
g++ -o yourapp src/main.o -Lpath/to/libs -lphp5 -lresolv
Hope this helps somebody one day :-)
I use some like this:
CFLAGS='-m32 -m64' LDFLAGS='-m32 -m64' CPPFLAGS="-m32 -m64" ./configure --prefix=/usr/local --disable-cli --enable-embed --build="build folder" --with-iconv-dir=/usr/local/opt/libiconv/
And enable cli later with phpize, this work with 5.2.10 and up.
Edit:
look here: http://forums.wxphp.org/viewtopic.php?f=6&t=42 it is my full resolution with makefile etc... for 5.4.17.
Related
I recently found out how to build a standalone php binary (here), which works great!
Is there a way to include the inotify extension into this binary?
I dont find any documentations about building php with inotiy, only about extend php with the "pecl extension" inotify - may this is the problem, its a pecl extension and therefore not includable into the php binary?
is there another approach to deliver the binary with this inotify extension (except normal php installation)?
Target is, to deliver a php cli application, which is independent of the installed php version of the destiantion server (which works great till now, until we would need the inotify extension in php..)
I just found this pretty documentation, which solved my problem.
INotify (and all other modules) works with the single static binary, compiled (in debian 7) via:
./configure --enable-static --enable-cli --enable-inotify --with-openssl --with-openssl-dir=/usr/bin
complete progress:
download /etxtract php711 source
download /extract inotify module
rename inotify folder to "inotify"
mv inotify folder to {phpsrc}/ext/inotify
change dir to {phpsrc}
rm configure
./buildconf --force
./configure --enable-static --enable-cli --enable-inotify --with-openssl --with-openssl-dir=/usr/bin
make
have fun with the stand alone php cli binary located # {phpsrc}/sapi/cli/php
The binary even works with other distributions (short tested in centos 6 and latest arch)
I am trying to integrate SQL Relay with PHP PDO on Windows (WAMP). I have installed and compiled Rudiments and SQL Relay on Windows through Visual Studio Developer Command Prompt following the instructions given on the Rudiments and SQL Relay SourceForge pages.
Then I downloaded the pdo_sqlrelay extension source from github and tried to build the dll for this extension.
In the build instructions, I couldn't find the ones pertaining to Windows specifically. I found instructions related to Linux. They are:
cd /path/to/pdo_sqlrelay
phpize
./configure --with-php-config=/path/to/php-config \
--with-pdo-sqlrelay=/path/to/sqlrelay/prefix \
--with-rudiments=/path/to/rudiments/prefix
make
make install
I tried to convert them to the relative Windows commands by following the step by step php extension build instructions on PHP's Wiki for building for Windows.
When I tried to execute the command, it threw a fatal error. (like undefined or invalid $remains).:
configure --disable-all --enable-cli --enable-$remains
I would appreciate if someone could help me out to build the pdo_sqlrelay extension on Windows.
you need to ...
first run bin\phpsdk_setvars.bat
to set up the build environment, so that $remains will be known as a variable.
then configure the build with buildconf (or buildconf --force for rebuilding).
then configure --disable-all --enable-cli --enable-$remains ... you probably might also want to --disable-zts (depending which PHP is being used).
it's rather nmake to build & nmake clean to clean.
to install & uninstall it's nmake install and nmake uninstall.
the documentation also states ...that:
First build and install Rudiments, then build and install SQL Relay.
I've tried to compile the PHP extension php_excel (v1.0.0) on VC9 with no luck, anyone able to provide guidance? I've used notes found on the web for compiling other PHP extensions as a reference but there are so many unknowns, I'm not a C developer so please bear with me. I would like to know how to compile extensions but if someone was able to just compile it for me I would still very much appreciate it.
Update: Step-by-step process below to SUCCESSFULLY compile the php_excel extension
INSTALLATION
============
Install Microsoft Windows Server 2003 x86 incl. Service Packs
Install Microsoft .NET Framework 2.0
Install Microsoft Windows SDK v6.1 (6.0.6001.18000.367-KRMSDK_EN.iso)
Install en_visual_studio_2008_professional_x86_dvd_X14-26326.iso
Install en_visual_studio_2008_service_pack_1_x86_dvd_x15-12962.iso
Install Microsoft Visual C++ 2008 SP1
Extract php-sdk-binary-tools-20110915.zip to C:\php-sdk
Extract deps-5.3-vc9-x86.7z to C:\php-sdk\phpdev\vc9\x86\deps
Extract php-5.3.28-src.zip to C:\php-sdk\phpdev\vc9\x86\php-5.3.28
Open Microsoft Windows SDK v6.1 > CMD Shell
COMMANDS (to compile PHP)
=========================
setenv /x86 /xp /release
cd /d c:\php-sdk\
bin\phpsdk_setvars.bat
bin\phpsdk_buildtree.bat phpdev
cd /d C:\php-sdk\phpdev\vc9\x86\php-5.3.28
buildconf
configure --help
configure --enable-apache2-2handler --with-curl --enable-fileinfo --enable-mbstring --enable-mbregex --with-mcrypt --with-openssl --with-pgsql --enable-sockets --with-mysql --with-mysqli --enable-pdo --with-pdo-mysql --with-pdo-mssql --with-pdo-pgsql --enable-soap --with-xmlrpc --with-xsl
nmake
nmake clean all
LibXL (additional steps)
========================
Extract php_excel-1.0.0.zip to C:\php-sdk\phpdev\vc9\x86\php-5.3.28\ext\excel
Extract \libxl-3.5.4.1\include_c\* to C:\php-sdk\phpdev\vc9\x86\deps\include\libxl
Extract \libxl-3.5.4.1\lib\libxl.lib to C:\php-sdk\phpdev\vc9\x86\deps\lib\libxl.lib
buildconf
configure --with-excel=shared
nmake
php_excel (branch v1.0.0)
https://github.com/iliaal/php_excel/tree/v1.0.0
LibXL for Windows 3.5.4
http://www.libxl.com/download.html
System:
Windows Server 2003 R2
PHP 5.3
Apache 2.2
php_excel 1.0.0
LibXL 3.5.4.1
Visual Studio 2008 (VC9)
Snapshots was made available under http://windows.php.net/downloads/pecl/snaps/excel/20140606/
Though I'm not sure there's no legal issue redistributing the libxl that way, so no guarantee for how long the builds may stay there. If you're intended to continuously use this library, please decide to file an issue to the origin repository about proposing the extension to PECL. Being in PECL will bring many advantages as we'll be able to continuously support it, also automatic builds will be available.
For building extensions yourself, see https://wiki.php.net/internals/windows/stepbystepbuild . The most important thing regarding VC9 - be sure using service pack 1. Be informed that everyone is welcome to ask questions on PECL mailing lists and #php.pecl on efnet.
Just to mention - as alternative you could use the com_dotnet extension available in the core to achieve the goals.
Thanks.
I've set up a github repository for building php_excel with VC11. It may help you to compile php_excel for VC9. see https://github.com/johmue/win-php-sdk-builder
To anyone looking for the latest Windows builds of php_excel.dll: I have upgraded all my builds to php_excel from git head at https://github.com/iliaal/php_excel, combined with the latest LibXL.
My Windows builds can be found at http://www.apachelounge.com/viewforum.php?f=6
All flavours are available: PHP 5.3/5.4/5.5/5.6/7.0/7.1/7.2/7.3/7.4, TS/NTS, x86/x64. The zips contain a phpinfo.htm with more info on all the extensions in the builds.
Before compiling new PHP-versions I always do a git pull from the master repositories, so hopefully the php_excel.dll's will be up-to-date for a long time.
I'm trying to cross compile php for arm and have good progress but I'm totally stuck where it wants to run the php itself (have no idea why). as it is an arm binary and not intel (my building platform) it won't run:
/bin/sh: /path-to-build/sapi/cli/php: cannot execute binary file
How can I fix this? The configure script understood I'm cross compiling but didn't do anything about it (from configure log):
checking whether the C compiler (/path-to-compiler/arm-none-linux-gnueabi-gcc) is a cross-compiler... yes
I'm compiling php-5.3.6 with configure command line:
export CC=/path-to-cc/arm-none-linux-gnueabi-gcc
../configure --prefix=/prefix-path/ --host=arm-none-linux-gnueabi
--disable-libxml --disable-dom --disable-openssl
--without-iconv --without-openssl --disable-simplexml
--disable-xml --disable-xmlreader --disable-xmlwriter
--without-pear --without-sqlite --without-sqlite3
--disable-pdo --without-pdo-sqlite
I was able to resolve this my own by disabling phar. I hope disabling so much modules won't break something internal.
Build without cross compiling and then, when cross compiling, point to the host version of php by overrididing a variable in the makefile on the command line when running make.
Something like:
make PHP_VAR_NAME=path to php built for host
I managed to compile PHP for arm with the following parameters:
export PATH="$PATH:/toolchains/gnu_cortex-a9_tools/usr/bin"
export ARCH=arm
configure script:
./configure --build=x86_64-unknown-linux-gnu --host=arm-linux-uclibcgnueabi --prefix=/usr/arm CC="arm-linux-uclibcgnueabi-gcc --sysroot=/toolchains/gnu_cortex-a9_tools/" --disable-libxml --disable-dom --without-iconv --without-openssl --disable-simplexml --disable-xml --disable-xmlreader --disable-xmlwriter --without-pear --without-sqlite3 --disable-pdo --without-pdo-sqlite --disable-phar
followed by
make
I managed to solve similar issue while cross-compiling PHP 5.6.0 by editing Makefile after running configure script. Just replace all occurrences of
$(top_builddir)/$(SAPI_CLI_PATH)
with
/usr/bin/php
Where /usr/bin/php is your host php cli. Make sure it is installed, e.g., sudo apt-get install php5-cli for Debian/Ubuntu.
After doing so phar extension builds fine
I have installed MAMP and the PHP it came with wasn't compiled with ncurses. I've tried to use port to install ncurses and it seems that it already exists on my system so now I was wondering if there was a way to get PHP to use it without having to recompile PHP --with-ncurses.
In other words: Can PHP be configured to use ncurses without the recompilation?
I'm sorry for the late answer but this can actually be done quite easily with MAMP.
I have done this on my MacBook running OS X Snow Leopard.
Your MAMP directory contains the tar file of the php source code. MAMP version 1.8.4 ships with php-5.2.11.tar located here: /Applications/MAMP/bin/php5/
cd /Applications/MAMP/bin/php5/
tar -xvf php-5.2.11.tar
cd php-5.2.11/ext/ncurses
/Applications/MAMP/bin/php5/bin/phpize
./configure --with-php-config=/Applications/MAMP/bin/php5/bin/php-config
make
make install
Afterwards you just need to add the ncurses.so extension to the MAMP php.ini
echo "extension=ncurses.so" >> /Applications/MAMP/conf/php5/php.ini
php -i | grep ncurses
This gives me:
ncurses
ncurses support => enabled
ncurses library version => 5.7
You can also do this with the PCNTL extension ;) ;)
Cheers!
According to the manual, ncurses must be compiled in. Some extensions can be compiled as shared libraries (dll/so) and loaded dynamically, but some can't. Seems that ncurses can't.
I don't know a lot about how mac packages are structured, but isn't it a bsd/ports style installation? In that case, just find the package and configure + recompile it.
Edit: I see that mamp is a binary distribution. You're out of luck then. I would suggest that you install at least php from sources. It's very useful to be able to install new extensions etc. It's fairly straight forward to compile php, so even if you aren't completely confident with compiling stuff, you should be able to huddle through it.