Hi, I've been trying to compile PHP on Windows for days.

I have had zero success and would appreciate some help/advice from anyone who has done it.

Following the instructions at:

http://www.php.net/manual/en/install.windows.php#install.windows.build

I have done the following:

Downloaded cygwin (the latest version, setup is 2.249.2.5) and installed it. At first I only installed the default options, but went back and installed the entire "Devel" subtree.

I compiled a simple 'hello world' .c file using gcc to create an 'a.exe'. Just for kicks, I include "sys/types.h" and it all works fine under gcc.

Now, getting back to PHP and Visual Studio:

I downloaded php-4.2.2.tar.gz from php.net, unpacked it, and located the .DSW files in the win32 directory.

I opened the php4ts.dsw workspace and see there are several projects for the php core libs, the test suites, the command line version, and interfaces for different webservers (Apache, AOLServer, etc).

According to the documentation, I add c:\cygwin\usr\include directory to my MS Visual Studio's

Tools->Options😃irectories 'Include Directories'

listbox.

I try building php4ts_cli project.

It immediately kicks out with:

Compiling...
php_cli.c
c:\cygwin\usr\include\sys/types.h(133) : error C2632: 'long' followed by 'long' is illegal
c:\cygwin\usr\include\sys/types.h(135) : error C2632: 'long' followed by 'long' is illegal
c:\cygwin\usr\include\sys/types.h(218) : warning C4005: 'FD_SET' : macro redefinition
        C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\winsock.h(83) : see previous definition of 'FD_SET'
c:\cygwin\usr\include\sys/types.h(219) : warning C4005: 'FD_CLR' : macro redefinition
        C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\winsock.h(78) : see previous definition of 'FD_CLR'
c:\cygwin\usr\include\sys/types.h(220) : warning C4005: 'FD_ISSET' : macro redefinition
        C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\winsock.h(87) : see previous definition of 'FD_ISSET'
c:\cygwin\usr\include\sys/types.h(226) : warning C4005: 'FD_ZERO' : macro redefinition
        C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\winsock.h(85) : see previous definition of 'FD_ZERO'
..\main\win95nt.h(11) : error C2371: 'uid_t' : redefinition; different basic types
        c:\cygwin\usr\include\sys/types.h(159) : see declaration of 'uid_t'
..\main\win95nt.h(12) : error C2371: 'gid_t' : redefinition; different basic types
        c:\cygwin\usr\include\sys/types.h(160) : see declaration of 'gid_t'
..\main\win95nt.h(35) : warning C4142: benign redefinition of type
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\time.h(84) : warning C4142: benign redefinition of type
c:\cygwin\usr\include\sys/stat.h(122) : warning C4273: 'chmod' : inconsistent dll linkage.  dllexport assumed.
c:\cygwin\usr\include\sys/stat.h(125) : warning C4003: not enough actual parameters for macro 'mkdir'
c:\cygwin\usr\include\sys/stat.h(125) : warning C4273: '_mkdir' : inconsistent dll linkage.  dllexport assumed.
c:\cygwin\usr\include\sys/stat.h(128) : warning C4273: 'umask' : inconsistent dll linkage.  dllexport assumed.
[...many more errors...]

I see that in cygwin sys/types.h uses "long long" to define a 64 bit value, but Microsoft calls them "int64". I can change the cygwin typedefs from long long to int64, but it's hard to think that this would be required without someone describing this somewhere...

I also see I have definition problems between the Unix version of socket utilities and the WinSock version. I believe there is some cygwin define I can set to alter that behavior, but I want to address the "long long" problem before I go there.... but if you know it off the top of your head, please let me know.

My goal is to have a small program where I can link with the php library, instance a PHP engine, and call API functions like php_execute_script().

but if I can't build the command-line version of PHP, I'm dead in the water.

Is this a PHP problem, a Cygwin problem, or a Me problem?

Thanks for any help you can provide.

    You dont have to compile PHP to get it to work with windows. All you need to to do is download the precompiled binaries from here. Read the install.txt file and it will tell you EXACTLY what to do.

      Thanks for your response.

      I found the problem with my setup, I had renamed an include file in MS Visual Studio:

      C:\DevStudio\VC\include\sys\types.h

      and failed to rename it back, and that was the cause of all my headaches.

      Good night!

        Write a Reply...