# Building extension for Mac OS X

- Thread: https://externals.io/message/19124
- Original archive: https://news-web.php.net/php.internals/19124
- Started by Fredrik Olsson on 2005-09-22T13:48:07+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #19124 — Fredrik Olsson — 2005-09-22T13:48:07+00:00

URL: https://externals.io/message/19124#19124

I use the binary installation of PHP 5.0.4 from 
http://www.entropy.ch/software/macosx/php/

And a tiny test case trying to introduce the module hello, with the 
function hello_world() that simply returns a string.  Actually I have 
just used copy and paste from this tutorial http://tinyurl.com/cahsj

At first I ran
php -r 'echo hello_world();'
With "Fatal error: Call to undefined function:  hello_world() in Command 
line code on line 1" as result.
I checked into it and reallies that the default php was php 4, so I tried:

/usr/local/php5/bin/php -r 'echo hello_world();'
To be sure.
This yields a better result :)
PHP Warning:  PHP Startup: : Unable to initialize module
Module compiled with module API=20020429, debug=0, thread-safety=0
PHP    compiled with module API=20041030, debug=0, thread-safety=0
These options need to match

No problem, my guess is that #include "php.h" for some reason uses the 
php4 header file. How do I force phpize, ./configure, #include "php.h" 
etc, to use the installed php5 files (All residing under /usr/local/php5)?

regards
	Fredrik Olsson

---

## #19126 — Rasmus Lerdorf — 2005-09-22T14:37:33+00:00

URL: https://externals.io/message/19124#19126 · In reply to: #19124

Fredrik Olsson wrote:
> I use the binary installation of PHP 5.0.4 from
> http://www.entropy.ch/software/macosx/php/
> 
> And a tiny test case trying to introduce the module hello, with the
> function hello_world() that simply returns a string.  Actually I have
> just used copy and paste from this tutorial http://tinyurl.com/cahsj
> 
> At first I ran
> php -r 'echo hello_world();'
> With "Fatal error: Call to undefined function:  hello_world() in Command
> line code on line 1" as result.
> I checked into it and reallies that the default php was php 4, so I tried:
> 
> /usr/local/php5/bin/php -r 'echo hello_world();'
> To be sure.
> This yields a better result :)
> PHP Warning:  PHP Startup: : Unable to initialize module
> Module compiled with module API=20020429, debug=0, thread-safety=0
> PHP    compiled with module API=20041030, debug=0, thread-safety=0
> These options need to match
> 
> No problem, my guess is that #include "php.h" for some reason uses the
> php4 header file. How do I force phpize, ./configure, #include "php.h"
> etc, to use the installed php5 files (All residing under /usr/local/php5)?

How about: /usr/local/php5/bin/phpize  ?

-Rasmus

---

## #19139 — Fredrik Olsson — 2005-09-23T06:18:51+00:00

URL: https://externals.io/message/19124#19139 · In reply to: #19126

Rasmus Lerdorf skrev:
> Fredrik Olsson wrote:
> 

<snip>

> > […]
> 
> 
> How about: /usr/local/php5/bin/phpize  ?
>
Unfortunately not quite as easy :(.


> -Rasmus

---

## #19143 — D. Walsh — 2005-09-23T15:17:41+00:00

URL: https://externals.io/message/19124#19143

> Hi.
>
> As you replied to my e-mail I guess it is ok to do the same. Just a  
> shame that a possible solution will not remain in the list for  
> others to see :/.

unfortunately the list doesn't tag the reply to so hitting reply goes  
to the sender.

> D. Walsh skrev:
>
>
> > […]
> <snip>
>
>
> > […]
> The first line does not work at all, so I tried it as
>    /usr/local/php5/bin/phpize LDFLAGS="-L/usr/local/php -L/usr/ 
> local/php/lib" CPPFLAGS=-I/usr/local/ php5/include
> And then the rest.

pushd /usr/local

ln -shf php5 php

popd

  /usr/local/php/bin/phpize LDFLAGS="-L/usr/local/php -L/usr/local/ 
php/lib" CPPFLAGS=-I/usr/local/php/include

./configure [options] LDFLAGS="-L/usr/local/php -L/usr/local/php/lib"  
CPPFLAGS=-I/usr/local/php/include

make

sudo make install

> It then installs the resulting module in /usr/lib/php/extensions/no- 
> debug-non-zts-20020429/, and that is the extensions_path for my  
> php4 install. So I manually copied my hello.so to /usr/local/php5/ 
> lib/, and got wrong version number again.
> I can not quite see why I should use /usr/local/php/ for LDFLAGS as  
> that path does not exist (The linker also warns about this).
> So I tried this:
>    /usr/local/php5/bin/phpize LDFLAGS="-L/usr/local/php5 -L/usr/ 
> local/php5/lib" CPPFLAGS=-I/usr/local/php5/include
>    ./configure --enable-hello LDFLAGS="-L/usr/local/php5 -L/usr/ 
> local/php5/lib"  CPPFLAGS=-I/usr/local/php5/include
>    make
>    sudo make install
> It still tries to install in the php4-directory. So I again  
> manually copied the hello.so. Allas the error remains:
>    peylow$ /usr/local/php5/bin/php -r 'echo hello_world();'PHP  
> Warning:  PHP Startup: : Unable to initialize module
>    Module compiled with module API=20020429, debug=0, thread-safety=0
>    PHP    compiled with module API=20041030, debug=0, thread-safety=0
>    These options need to match
>
>
> > […]
> I checked this page, as I thought it might be a problem with me  
> using a binary install from entopy, and you use this one. But I can  
> not find any way to download and install this one, am I missing  
> something?

I do not use the entrophy PHP, I build from scratch.

>
> > […]
>
> Regards
>
> -- 
> //Fredrik Olsson

-- Dale
