Documentation Install

From RLIB

Jump to: navigation, search

Installation from source under Windows

RLIB uses the autoconf framework for detecting dependencies. This is not a native Windows development environment, so compilation from source needs substantial preparation before compilation can be attempted.

  1. Install Windows XP (or some other version, W2000 or newer) Skip this step if you already have it.
  2. Install MinGW from http://www.mingw.org or http://sourceforge.net/projects/mingw/ using its installer, current version is 5.1.4. Choose Full Install.
  3. Install MSYS 1.0.10 (current release, not "technology preview") also from the above SourceForge page. This provides POSIX compatible shell (rxvt with bash), etc. so "./configure" may run.
  4. Install these software from http://gnuwin32.sourceforge.net/ below (all three packages of Binaries, Developer files and Dependencies). Their so called "installation" is actually extracting the ZIP files under C:\MinGW.
    • libiconv
    • gd
    • freetype
    • jpeg
    • libpng
    • libgw32c
  5. Install GTK for Windows (GLIB is a part of GTK that RLIB uses): http://www.gtk.org/download-windows.html Choose the "bundle" version which contain all 3rd party dependencies of GTK/GLIB and also developer files. (C headers, etc.): http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.12/gtk+-bundle-2.12.10.zip This contains a "win_iconv" DLL instead of "GNU iconv", which is a drop-in replacement for GNU iconv with smaller footprint. Unzip the above ZIP into the directory where you installed MinGW, e.g. into C:\MinGW.
  6. Install libxml2 from http://www.zlatkovic.com/libxml.en.html , binaries at: http://www.zlatkovic.com/pub/libxml/ Latest at the time of writing is http://www.zlatkovic.com/pub/libxml/libxml2-2.6.32+.win32.zip This ZIP contains the usual UNIX-like directory structure with bin/, include/ and lib/ with a root directory called libxml2-2.6.32+.win32/. Extract this ZIP and move all its subdirectories from its root to C:\MinGW. Copy the text below to a file named as "libxml-2.0.pc" to C:\MinGW\lib\pkgconfig directory.
    prefix=/mingw
    exec_prefix=/mingw
    libdir=/mingw/lib
    includedir=/mingw/include
    Name: libXML
    Version: 2.6.32
    Description: libXML library version2.
    Requires:
    Libs: -L${libdir} -lxml2 -lz
    Cflags: -I${includedir}/libxml -I${includedir}/libxml2
  7. Install GD from http://gnuwin32.sourceforge.net/packages/gd.htm Choose the "Complete package, except sources"
  8. Install Python-2.5.2 from http://www.python.org/download/. Choose Full Install.
  9. Install ActivePerl 5.10 or 5.8 from http://www.activestate.com/downloads/ Tested with 5.10.0 Build 1003
  10. Install Sun JDK 6u6 from http://java.sun.com
  11. Install .NET Framework (1.1, 2.0 or 3.5) and its SDK from http://www.microsoft.com.
  12. Install Mono for the mcs.exe command line compiler: http://ftp.novell.com/pub/mono/archive/1.9.1/windows-installer/2/mono-1.9.1-gtksharp-2.10.4-win32-2.exe then rename "mcs.bat" so it doesn't take preference over the "mcs" shell script:
    • mv /c/Program\ Files/Mono-1.9.1/bin/mcs.bat /c/Program\ Files/Mono-1.9.1/bin/mcs.batch
  13. Install PostgreSQL for Windows from http://www.postgresql.org Tested with PostgreSQL 8.3.3-1 release. Choose Full Install. Do not need to run Stack Builder (exit).
  14. Install a MySQL community server from www.mysql.com (5.0.51b was tested). Installation instructions can be found at http://dev.mysql.com/downloads/mysql/5.0.html#win32.
  15. Download http://wyw.dcweb.cn/reimp_new.zip Unzip it somewhere in your MSYS home directory.
    I suppose you extracted it in C:\msys\home\1.0\<username>\reimp:
    $ cd reimp/src
    $ make
    $ cp reimp.exe /mingw/bin
  16. Then follow the instructions found at http://forums.mysql.com/read.php?45,64209,72004 to create a MinGW compatible libmysql.a to link with, quote:
    • Install mingw-utils (from mingw.org) (for reimp.exe and dlltool.exe ) (already done)
    • Install native mysql Win Version (already done)
    • copy manually $(MYSQL_PATH)/lib/opt/* to C:\MingW\lib\mysql\
    • copy manually $(MYSQL_PATH)/include/* to C:\MingW\include\mysql\
    • launch msys
    • cd /mingw/lib/mysql
    • reimp.exe libmysql.lib
    • mv liblibmysql.a libmysql.a
  17. Similar procedure is needed for the Perl distribution:
    • $ cd /c/Perl/lib/CORE
    • $ reimp.exe perl510.lib
    • $ mv libperl510.a /mingw/lib/libperl.a
  18. Also, for Python 2.5:
    • $ cd /c/Python25/libs
    • $ reimp.exe python25.lib
    • $ mv python25.a /mingw/lib/libpython2.5.a
  19. Add these directories to Windows PATH:
    • C:\Program Files\MySQL\MySQL Server 5.0\scripts
    • C:\Program Files\PostgreSQL\8.3\bin
    • C:\Program Files\GnuWin32\bin
    • C:\Python25
    Perl added its directories automatically.
  20. Copy these files from C:\MinGW\bin to C:\MinGW\lib:
    • libxml2.dll
    • libpng*.dll
  21. Copy these files to C:\MinGW\lib:
    • C:\Program Files\PostgreSQL\8.3\bin\libpq.dll
    • C:\Program Files\PostgreSQL\8.3\lib\libpq.lib
  22. Download and extract a stable source release.
    • You may download the CVS version but you have to prepare it under Linux to create the "configure" script by running "./autogen.sh".
  23. Enter the source directory "cd rlib-<version>"
  24. Run
    ./configure --prefix=/mingw --with-pythonver=2.5 --with-csharp=/c/Program\ Files/Mono-1.9.1 --with-java=/c/Program\ Files/Java/jdk1.6.0_06
    This is a single but long line
  25. Run "make"
  26. Run "make install"
  27. Collect the following DLLs from C:\MinGW\lib and put it somewhere in PATH:
    • librpdf.dll
    • libr.dll
    • libr-postgres.dll
    • libr-mysql.dll
    • libr-odbc.dll
    The language bindings (Perl, Python, etc.) were copied to their needed places, where the appropriate interpreter can access it.
  28. If you need to use RLIB from a C project, you will also need the header files from C:\MinGW\include\rlib.

Compiling the PHP binding under Windows

  1. Install PHP/Windows from http://www.php.net Latest version at the time of writing was 5.2.6.
  2. Download the source for the same PHP version you just installed. Extract it somewhere.
  3. Install Visual Studio 2008 Express
  4. Add the directories below to PATH:
    • C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE
    • C:\Program Files\Microsoft Visual Studio 9.0\VC\bin
  5. Use the documentation link below to create a Visual C++ project called "rlib":
    http://www.talkphp.com/vbarticles.php?do=article&articleid=49&title=creating-custom-php-extensions
    Do not yet build it.
  6. When the all of the other parts of RLIB were built, enter these commands:
    • $ cd libsrc
    • $ lib /machine:i386 /DEF:libr.def
    • $ cp libr.lib /c/Documents\ and\ Settings/<username>/My\ Documents/Visual\ Studio\ 2008/Projects/rlib/rlib/
    This created an MSVC-compatible import library that will be used for building the PHP extension, i.e. to link with libr.dll.
  7. Copy the relevant files to the newly created project:
    1. In the "rlib-x.y.z" diretory:
      • $ cp config.h /c/Documents\ and\ Settings/<username>/My\ Documents/Visual\ Studio\ 2008/Projects/rlib/rlib/
    2. In "rlib-x.y.z/libsrc":
      • $ cp *.h /c/Documents\ and\ Settings/<username>/My\ Documents/Visual\ Studio\ 2008/Projects/rlib/rlib/
    3. In "rlib-x.y.z/bindings/php":
      • $ cp array_data_source.c environment.c php.c rlib_php.h /c/Documents\ and\ Settings/<username>/My\ Documents/Visual\ Studio\ 2008/Projects/rlib/rlib/
    Add these newly copied files to the project.
  8. Edit stdafx.h, add these line at the end:
    • #include "config.h"
    • #include "config.w32.h"
    • #include "zend_config.w32.h"
    • #include "php.h"
  9. Edit php.c and delete the following line:
    • #include <config.h>
    and add the following line:
    • #include "stdafx.h"
  10. Also, copy these files and directories from C:\MinGW\include to a new directory, say C:\msys\1.0\home\<username>\include and add the new directory to the Project properties under C/C++ -> General -> Additional Include Directories so the build will find them, but the MinGW headers don't clash with Visual Studio's:
    • glib-2.0/
    • iconv.h
    • libxml/
    Also, copy C:\MinGW\lib\glib-2.0\include\glibconfig.h to the newly copied glib-2.0/ directory.
  11. The above documentation link tells to uncomment the following line in zend_config.w32.h to prevent a warning:
    • #define vsnprintf _vsnprintf
  12. Also, this PHP bug also bit me: http://bugs.php.net/bug.php?id=39130 So, the following two lines have to be commented out also in config.w32.h:
    • #define _USE_32BIT_TIME_T 1
    • #define HAVE_STDLIB_H 1
  13. Edit all C source files so instead of:
    • #include <config.h>
    they contain:
    • #include "stdafx.h"
  14. Edit rlib_input.h, so it contains:
    • #include "charencoder.h"
    instead of:
    • #include <charencoder.h>
  15. Now you can build it and php_rlib.dll will be created.
Personal tools