internals:windows:libs:libpg

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
internals:windows:libs:libpg [2008/07/23 16:47] pajoyeinternals:windows:libs:libpg [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 3: Line 3:
 ===== Building LibPq 8.3.x ===== ===== Building LibPq 8.3.x =====
  
 +For PHP suitable sources and up-to-date information see [[https://github.com/winlibs/postgresql]]
 ==== Requirements ===== ==== Requirements =====
   * Common tools used to compile PHP   * Common tools used to compile PHP
   * Native Perl from ActiveState ([[http://www.activestate.com/Products/activeperl/]]) installed and perl being in your PATH   * Native Perl from ActiveState ([[http://www.activestate.com/Products/activeperl/]]) installed and perl being in your PATH
-  * Postgresql sources ([[http://pecl2.php.net/downloads/php-windows-builds/source/]] Custom sources for VC6)+  * Postgresql sources ([[https://github.com/winlibs/]] Custom sources for VC6)
  
 ==== Dependencies ==== ==== Dependencies ====
-  * OpenSSL build ([[http://pecl2.php.net/downloads/php-windows-builds/php-libs/]]) +  * OpenSSL build ([[http://windows.php.net/downloads/php-sdk/deps/]]) 
-  * ZLib build ([[http://pecl2.php.net/downloads/php-windows-builds/php-libs/]])+  * ZLib build ([[http://windows.php.net/downloads/php-sdk/deps/]])
  
-==== Configure  =====+==== Modification to the config scripts (all VCs) ===== 
 + 
 +The ready to be used sources are available in our source repository [[https://github.com/winlibs/]]. However this section describes the changes required for postgresql 8.3.3. They should work for other 8.3.x releases (hopefully :) 
 + 
 +To make it works smoothly with our libraries, it is first needed to modify the script to look for: 
 +  * zlib.lib instead of zdll.lib 
 +  * ssleay32.lib instead of ssleay32MD.lib 
 +  * libeay32.lib instead of libeay32MD.lib 
 + 
 +and for the debug versions: 
 +  * zlib_debug.lib instead of zdll.lib 
 +  * ssleay32_debug.lib instead of ssleay32MDd.lib 
 +  * libeay32_debug.lib instead of libeay32MDd.lib 
 + 
 +To do so, open src\tools\msvc\Solution.pm (line 332): 
 +<code perl> 
 +$proj->AddLibrary($self->{options}->{zlib} . '\lib\zlib.lib'); 
 +</code> 
 + 
 +The configuration option given through the command line does not work. Edit the src\tools\msvc\config.pl to define the correct path. Here is an example using my local config: 
 + 
 +<code perl> 
 +our $config = { 
 +    asserts=>0, # --enable-cassert 
 +    integer_datetimes=>0,   # --enable-integer-datetimes 
 +    nls=>undef, # --enable-nls=<path> 
 +    tcl=>'c:\tcl', # --with-tls=<path> 
 +    perl=>'c:\perl', # --with-perl 
 +    python=>'c:\python24', # --with-python=<path> 
 +    #krb5=>'c:\prog\pgsql\depend\krb5', # --with-krb5=<path> 
 +    krb5=>0, 
 +    ldap=>0, # --with-ldap 
 +    openssl=>'c:\Users\pierre\Documents\php-sdk\vc8\x86\deps', # --with-ssl=<path> 
 +    uuid=>'c:\prog\pgsql\depend\ossp-uuid', #--with-ossp-uuid 
 +    xml=>'c:\Users\pierre\Documents\php-sdk\vc8\x86\deps', 
 +    xslt=>'c:\prog\pgsql\depend\libxslt', 
 +    iconv=>'c:\prog\pgsql\depend\iconv', 
 +    zlib=>'c:\Users\pierre\Documents\php-sdk\vc8\x86\deps'# --with-zlib=<path> 
 +}; 
 +</code> 
 + 
 +Nothing else is necessary as long as the VC version is 2005 or later. See the next section for the changes I applied for the VC6 builds. 
 + 
 +==== Modification to the sources (VC6) only ===== 
 + 
 +libpq relies on SHGetFolderPath which is not available in the Platform SDK used by VC6 (2003/02). Modify the file \src\backend\libpq\fe-connect.c (line 3812) as follow: 
 + 
 +<code C> 
 +#ifndef SHGetFolderPath 
 +
 +HMODULE shfolder = LoadLibrary("shfolder.dll"); 
 +FARPROC qSHGetFolderPath; 
 +#define CSIDL_PROGRAM_FILES 38 
 +#define CSIDL_APPDATA 0x001a 
 +char szPath[MAX_PATH]; 
 + 
 +shfolder = LoadLibrary("shfolder.dll"); 
 +if(shfolder == NULL) { 
 + return false; 
 +
 + 
 + 
 +qSHGetFolderPath = GetProcAddress(shfolder, "SHGetFolderPathA"); 
 +if (qSHGetFolderPath == NULL) { 
 + FreeLibrary(shfolder); 
 + return NULL; 
 +
 + 
 +if (qSHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, szPath)) { 
 + FreeLibrary(shfolder); 
 + return NULL; 
 +
 + 
 +
 +#else 
 + if (SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, tmppath) != S_OK) 
 + return false; 
 +#endif 
 +</code> 
 + 
 + 
 +Further changes have to be done after having run the configure scripts, to update pg_config.h, pg_config_os.h, see the next section for the details. 
 + 
 +==== Compile ===== 
 + 
 +The automatic build works smoothly for VC8 and VC9. However it is not compatible with VC6, the generated files have to be slightly modified after that build.bat has been called (and failed with many errors).
  
-Configure for Win32 
 <code bash> <code bash>
-cd  C:\php-sdk\vc9\x86\libs_builds\postgresql-8.3.3+cd  C:\php-sdk\vc9\x86\libs_builds\postgresql-8.3.3\tools\msvc 
 + 
 +build.bat libpq
 </code> </code>
  
 +Modify src\src\include\pg_config.h as follow, line 136:
 +<code C>
 +/* Define to 1 if your compiler understands __FUNCTION__. */
 +#if _MSV_VER >= 1500
 +#define HAVE_FUNCNAME__FUNCTION 1
 +#endif
 +</code>
 +
 +SSPI auth is supported by the Platform SDK used by VC6, it has to be disabled:
 +<code C>
 +/*
 + * Always build with SSPI support. Keep it as a #define in case
 + * we want a switch to disable it sometime in the future.
 + */
 +#ifndef __BORLANDC__
 +# if _MSC_VER >= 1500
 +#  define ENABLE_SSPI 1
 +# endif
 +#endif
 +</code>
  
 ===== Compiling ===== ===== Compiling =====
  
 +For VC8 and VC9, the build.bat script works out of the box (with the config.pl changes). The dll should be in the Release or Debug directory.
 +
 +For VC6, open the pgsql.dsw (it has dozen of dsp, but we need only two) in VC6. Build first libpgport then libpq. The dependency requires a change:
 +
 +   * drop secur32.lib (odbc*, ole*, gdi* as well but they are harmless)
 +
 +It may not find the .lib or headers for openssl or zlib, in that case simply fix the project settings:
 +
 +   * Add ..\..\..\deps\include to the include path option
 +   * Add ..\..\..\deps\lib to the additionals library path option
  
 +Absolute path works as well but they make your tree path dependent. These relative paths will work by default with the php-sdk.
internals/windows/libs/libpg.1216831624.txt.gz · Last modified: 2017/09/22 13:28 (external edit)