php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45698 Doesn't compile with VC6 - Include problem
Submitted: 2008-08-03 12:23 UTC Modified: 2008-08-23 23:59 UTC
From: Keisial at gmail dot com Assigned: pajoye (profile)
Status: Not a bug Package: Compile Failure
PHP Version: 5.3CVS-2008-08-03 (snap) OS: Windows - VC6
Private report: No CVE-ID: None
 [2008-08-03 12:23 UTC] Keisial at gmail dot com
Description:
------------
5.3 doesn't compile with VC6. When including winsock2.h at zend_config.w32.h it includes windows.h which in turn includes winsock stuff before a SOCKET is defined. Compilation fails with error on mswsock.h
(This doesn't happen including only those two headers, so some defines are modifying the defualt behaviour)

Changing the order to include windows.h before winsock2.h fixes it:
--- zend_config.w32.h   2008-07-17 20:33:46.000000000 +0200
+++ zend_config.w32.h   2008-08-03 14:19:56.593750000 +0200
@@ -35,8 +35,8 @@
 #ifndef ZEND_INCLUDE_FULL_WINDOWS_HEADERS
 #define WIN32_LEAN_AND_MEAN
 #endif
-#include <winsock2.h>
 #include <windows.h>
+#include <winsock2.h>

 #include <float.h>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-08-03 12:27 UTC] derick@php.net
This will probably fix the compile failure that Steph and I were getting...
 [2008-08-03 13:25 UTC] pajoye@php.net
Stas, can you commit the patch please?
 [2008-08-03 13:35 UTC] pajoye@php.net
Err no. 

Please do not commit this patch as it does break VC6 builds now.

Please use the following compilers SDK pairs:

http://wiki.php.net/internals/windows/compiler
http://wiki.php.net/internals/windows/windowssdk

This is what we use for http://snaps.php.net
 [2008-08-23 09:49 UTC] pajoye@php.net
I finally got some more time to investigate. Can you try the following:

- open a normal console
- "c:\program files\Microsoft Visual Studio\VC98\bin\vcvars32.bat"
- Do not register the SDK or VS vars, type "export<enter>" to be sure that no LIB or INCLUDE are defined (may be set to VC98 include or lib)

Then run:

configure.bat --with-extra-includes=c:\path\to\sdk200302\include --with-extra-libs=c:\path\to\sdk200302\lib

and finally nmake.

It may fix the problem as the correct winsock2 will be included.

The important thing to remember is that winsock2.h is a special case, it has to be included before windows.h (msdn or google about it).
 [2008-08-23 13:40 UTC] Keisial at gmail dot com
Thanks for your attention.
I had solved it by doing: set INCLUDE=C:\PROGRA~1\Microsoft Platform SDK\Include;%INCLUDE%

Just doing configure.bat "--with-extra-includes=C:\PROGRA~1\Microsoft Platform SDK\Include" "--with-extra-libs=C:\PROGRA~1\Microsoft Platf
orm SDK\lib" as you mention doesn't work, you still need the VC includes, or you get "fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory"

Some includes only have the platform sdk (windows.h, winsock2.h...) but don't provide standard headers. The newest use a deprecated attribute which is not recognised, mingw32 headers fail for gcc specific code...

Here are the different results i got when looking for a working combination:


C:\PROGRA~1\Microsoft Visual Studio 9.0\VC\include\crtdefs.h(548) : error C2485:
 'deprecated' : unrecognized extended attribute

C:\PROGRA~1\Microsoft Visual Studio 8\VC\include\crtdefs.h(556) : error C2485: '
deprecated' : unrecognized extended attribute

Zend\zend.h(37) : fatal error C1083: Cannot open include file: 'stdio.h': No suc

C:\PROGRA~1\Microsoft SDKs\Windows\v6.1\Include
No stdio.h

C:\PROGRA~1\Microsoft SDKs\Windows\v6.1\Include + VC6
C:\PROGRA~1\Microsoft SDKs\Windows\v6.1\Include\specstrings.h(9) : fatal error C
1083: Cannot open include file: 'sal.h': No such file or directory

C:\PROGRA~1\Microsoft Platform SDK\Include
No stdio

C:\PROGRA~1\Microsoft Platform SDK\Include + VC
Works


Mingw32 headers -> Fail for GCCisms

w32api headers + VC6
include\stdio.h(217) : error C2054: expected '(' to follow '
__inline__'
 [2008-08-23 15:29 UTC] pajoye@php.net
> I had solved it by doing: 
> set INCLUDE=C:\PROGRA~1\Microsoft Platform SDK\Include;%INCLUDE%

Great, that confirms the (old) winsock2 bug.

I'm updating our scripts so it can be used easily by anyone to setup an environment (be vc6 or vc9).

You can find them here:

http://cvs.php.net/php-internals-win/script/

Some docs will be added to the wiki as well.

 [2008-08-23 18:19 UTC] Keisial at gmail dot com
I didn't know you could cvs checkout a module called php5!
It isn't listed at http://cvs.php.net/

However, just running those scripts doesn't work, buildconf fails complaining that snap53\win32\build\buildconf.js wasn't found

If you want to make easy for anyone to build php on windows, you may find useful the script i use. It automatically pulls the latest snapshot, the requeriments (bindlib, libiconv, zlib, libxml2), builds php and moves the relevant files to a different Release folder.

It's not completely foolproof, but imho it's on the right path. If you're interested, send me an email or just /query me on irc.
 [2008-08-23 18:29 UTC] pajoye@php.net
> However, just running those scripts doesn't work, buildconf fails
> complaining that snap53\win32\build\buildconf.js wasn't found

Hm, did you check it to snap53?

> If you want to make easy for anyone to build php on
> windows, you may find useful the script i use. 
> It automatically pulls the latest snapshot, 
> the requeriments (bindlib, libiconv, zlib, libxml2), builds
> php and moves the relevant files to a different Release folder.

Well, 5.3 will have no dependency by default but a compiler. PHP6 depends on ICU only.

At some point, I may add one single zip per area, for the core (libxml2, libiconv, zlib) and per extension as well as some script to automatically fetch the lib from our downloads section (http://pecl2.php.net/downloads/php-windows-builds/php-libs/).

By the way, the snapshot scripts are used to build snapshots. I'm not sure it makes sense to use them for daily developments. Their main advantage is that they are callable from a scheduled task.

Ping on IRC? Where/who? :)

 [2008-08-23 18:49 UTC] Keisial at gmail dot com
> Hm, did you check it to snap53?
Yes. It doesn't seem to be exactly that. I got that error only once manually calling buildconf, the file is there. The actual error was "System can't found specified path", which is not too informative about which part of the bat failed :)

Now i removed echo hiding of buildconf during checkout, and the problem seem to be that configure was passed he flags --with-pdo-oci=C:\php-sdk\oracle\instantclient10\sdk,shared --with-oci8=C:\php-sdk\oracle\instantclient10\sdk,shared --with-oci8-11g=C:\php-sdk\oracle\instantclient11\sdk,shared

> Well, 5.3 will have no dependency by default but a compiler. PHP6
depends on ICU only.

You mean for unix system, isn't? Otherwise i should visit my psychologist, I see configure failing with:
ERROR: We really need that arpa\nameser.h file - it is part of the bindlib package
;)

t-build --enable-debug-pack --disable-fileinfo
At some point, I may add one single zip per area, for the core (libxml2,
> as well as some script to automatically fetch the lib from our > downloads section (http://pecl2.php.net/downloads/php-windows-builds/php-libs/).
That's what i'm using. Requisites: wget, unzip and tar 

>By the way, the snapshot scripts are used to build snapshots. I'm not
> sure it makes sense to use them for daily developments. Their main
> advantage is that they are callable from a scheduled task.

You would want at least different flags. I expect much more people wanting to develop on php than making snapshots.
The great advantage is not having to worry about compile options or configure flags. You can also happily delete your build folder and get everything refetched from scratch

> Ping on IRC? Where/who? :)
<answer removed> you already found me :)
 [2008-08-23 23:59 UTC] pajoye@php.net
Solved, the PSDK was not first in the INCLUDE path. It must be first both in LIB and INCLUDE.

Not a bug > bogus.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Nov 26 12:01:23 2020 UTC