From: Steven B. <ste...@gm...> - 2005-10-06 23:33:01
|
I apologize for the length of this post in advance. I have been longing to try the php-java-bridge(pjb) out but have been dissuaded because my servers are not going to migrate to php5 anytime in the near future and the task of compiling the pjb for windows seemed arduous. Many posters to the pjb list have indicated it should be possible to compile php4 for windows but I could not find many concrete explanations. I provide these instructions as a first step towards better instructions. I spent many hours and derived the following process which builds the pjb as a module (i.e. a dll to be put into the extensions directory) for use under windows with apache2 for php4. This was derived with much trial and error from the INSTALL file included with php-java-bridge-2.0.8.tar.bz2 (I tried with Visual Studio .Net; MS Visual c++ V6.0; and with Cygwin -- this was the only process I could get to work). I believe php5 has been made to be more user friendly when it comes to compiling on windows. After completing these steps I was able to get all the tests in the tests.php4 directory to work with the exception of the arrayArray.php which threw a nasty apache error. I will investigate further, soon. The two challenges in getting the pjb to compile are: 1. configuring the php_config.h file 2. building the .dll (which requires the php_config.h) with all of the necessary libraries/includes There is probably an easier way of doing this...but I know very little about building C code and even less about doing it on a windows platform. This has not been optimized (and I might have left something out...). I cannot guarantee these steps won't break your computer. Hopefully these steps are reproduceable by others...YMMV. =20 I also have not used this enough to understand if this creates a stable version of the pjb. 1. download mingw.exe (http://prdownloads.sourceforge.net/mingw/MinGW-4.1.0.exe?download) -- this is an installer run it and install to c:\mingw install current/full version of core, compilers, utilities (don't need sour= ces) edit your windows path (control panel->System->Advanced Tab->Environment Variables) to include c:\mingw\bin verify that you have got the path set properly by: start->run->cmd gcc -v 2. download and run msys.exe (http://prdownloads.sourceforge.net/mingw/MSYS-1.0.10.exe?download) -- install to c:\msys\1.0 directory (note: install msys after mingw) edit the file c:\msys\1.0\etc\fstab and add the following line: c:/src=09/src c:/j2sdk1.4.2_06 /java {make sure this is the path to your j2sdk} -- this might not be necessary still.... 3. download and run msys-dtk (http://prdownloads.sourceforge.net/mingw/msysDTK-1.0.1.exe?download) 4. download the php source (4.3.10 and 4.4.0 has been proven to work) and install to a directory (c:\src\php-4.3.10) 5. download the win32build.zip (http://www.php.net/extra/win32build.zip) and install to a directory (c:\src\win32build) 6. Add the following empty files into the win32build/include directories (they are necessary to satisfy #include requirements): /sys/poll.h /sys/wait.h 7. download the javabridge source (you will need the tar.bz2 version); extract and replace the php-4.3.10/ext/java directory with the javabridge src 8. Update the "m4_include" paths in ext\java\config.m4 so that they start with "ext/java/"; e.g.: m4_include(ext/java/tests.m4/function_checks.m4) 9. open a msys window (C:\msys\1.0\msys.bat) cd /src/php-4.3.10 ./buildconf --force ./configure 10. Edit the php source for the following: in php-4.3.10/main/win95nt.h comment out the following (add // in front of each line): #include <io.h> typedef unsigned int uint; typedef unsigned long ulong; typedef long pid_t; in php-4.3.10/tsrm/tsrm_virtual_cwd.h comment out the following (add // in front of each line): typedef unsigned short mode_t; in php-4.3.10/tsrm/tsrm_config.w32.h comment out the following (add // in front of each line): #include <crtdbg.h> 11. Edit the java.c in the java-bridge directory (the given function is not defined in php4?): Change: ********* #ifdef __MINGW32__ static const int java_errno=3D0; int *__errno (void) { return &java_errno; } #define php_info_print_table_row(a, b, c) \ php_info_print_table_row_ex(a, "java", b, c) #endif ********* To: ********* #ifdef __MINGW32__ static const int java_errno=3D0; int *__errno (void) { return &java_errno; } #ifdef ZEND_ENGINE_2 #define php_info_print_table_row(a, b, c) \ php_info_print_table_row_ex(a, "java", b, c) #endif #endif ********** 12. Change the order of includes in protocol.c in the java-bridge directory= : Change: ****************** #include "protocol.h" #include "php_java.h" #include "java_bridge.h" #include "php_java_snprintf.h" ****************** To: ****************** #include "php_java.h" #include "java_bridge.h" #include "php_java_snprintf.h" #include "protocol.h" ****************** 13. Change the order of includes in init_cfg.c.in the java-bridge directory= : Change: ****************** #include "protocol.h" #include "php_java.h" #include "java_bridge.h" ****************** To: ****************** #include "php_java.h" #include "java_bridge.h" #include "protocol.h" ****************** 14. create the following file build.bat into the javabridge directory with the following contents:: ::start build.bat ::this should be auto-set by cat ./VERSION set BRIDGE_VERSION=3D2.0.8 set PHP_JAVA=3D set COND_GCJ=3D0 set EXTENSION_NAME=3DJAVA set PHP_JAVA_BIN=3Djavaw set EXTENSION_DIR=3D../.. set PHP=3D../.. set SYS_INCLUDE=3D../../../win32build/include set SYS_INCLUDE2=3Dc:/mingw/include set SYS_WIN32=3D../../win32 ::this should be the path to your currently installed php4ts.dll set PHPTS=3D"../../../../php-4.3.10/php4ts" set GCC=3Dc:/mingw/bin/mingw32-gcc.exe sed "s*@PHP_JAVA@*%PHP_JAVA%*;s*@COND_GCJ@*%COND_GCJ%*;s*@PHP_JAVA_BIN@*%PH= P_JAVA_BIN%*;s*@EXTENSION@*%EXTENSION_NAME%*;s*@BRIDGE_VERSION@*%BRIDGE_VER= SION%*" <./init_cfg.c.in >./init_cfg.c sed "s*@PHP_JAVA@*%PHP_JAVA%*;s*@COND_GCJ@*%COND_GCJ%*;s*@PHP_JAVA_BIN@*%PH= P_JAVA_BIN%*;s*@EXTENSION@*%EXTENSION_NAME%*;s*@BRIDGE_VERSION@*%BRIDGE_VER= SION%*" <./init_cfg.h.in >./init_cfg.h rm *.o %GCC% -w -I%SYS_INCLUDE% -I%SYS_INCLUDE2% -I. -I%SYS_WIN32% -I%PHP% -I%PHP%/main -I%PHP%/Zend -I%PHP%/TSRM -D"ZEND_DEBUG=3D0" -D"TSRM_EXPORTS" -D"LIBZEND_EXPORTS" -D"ZTS" -D"_MBCS" -DCOMPILE_DL_JAVA -DPHP_WIN32 -DZEND_WIN32 -DCFG_JAVA_SOCKET_INET -D__MINGW__ -DWIN32 -DEXTENSION_DIR=3D\"%EXTENSION_DIR%\" -c *.c dllwrap --export-all-symbols -k *.o -L%PHP% -l%PHPTS% -lws2_32 -o php_jav= a.dll ::end build.bat 15. copy the php_java.dll and put it in the same directory as all of your other extensions...(in my case c:\php-4.3.10\extensions 16. Edit and add to php.ini: ;;start php.ini addendum [javabridge] extension =3D php_java.dll ;; log level between 0 (log off) and 4 (log debug). The default "log ;; file" is the standard output. The default level is 2. java.log_level=3D3 ;; If you don't have a servlet engine, double-click on JavaBridge.jar ;; to start the backend and uncomment the following option. java.socketname=3D9267 ;; If you have a servlet engine or an application server, deploy ;; JavaBridge.war and re-start the servlet engine or the application ;; server. Comment out the "java.socketname" option and uncomment ;; the following options. ;java.hosts=3D"127.0.0.1:8080" ;java.servlet=3DOn ;;end php.ini addendum 17. restart your apache server and confirm it works via instructions from the pjb. Regards, Steven Balthazor |