Menu

How to make php_odbtp.so on Leopard x64

Help
mneimeyer
2008-03-14
2013-04-22
  • mneimeyer

    mneimeyer - 2008-03-14

    Hey All,

    I'm not sure where this goes but I wanted to document how I was able to get odbtp compiled for use on Leopard OS X 10.5.

    This may be long winded but I also want people to be able to search on the various problems at each step and find it. (Since I couldn't)

    Basically, the stock PHP 5.2.4 that comes with Leopard does not include DBase support or ODBTP (obviously). So I did what I've always done before, install XCode, open phpinfo(); on the stock php install, grabbed the configure string, downloaded PHP 5.2.4, used that same configure string but added --enable-dbase=shared, ran make and then grabbed the resulting dbase.so. Downloaded the latest odbtp source, pointed it to the php I downloaded and compiled the shared odbtp extension. When I installed both of those I was getting errors like this... (this one happens to be from the ZendOptimizer...)

    dyld: NSLinkModule() error
    dyld: Symbol not found: _zend_extensions
      Referenced from: /usr/local/Zend/lib/ZendExtensionManager.so
      Expected in: flat namespace

    Googling seemed to indicate that the "flat namespace" thing was the result of differing thread safety levels in the PHP versus the shared object. I tried recompiling the whole of PHP to replace the built in libphp5.so for apache... but running that failed... I don't have the exact errors but basically found out that Leopard is ALL 64-bit. So when Apache x64 tried to load PHP x32 it failed. Apparently the stock install of XCode doesn't compile x64 code by default. Some googling led me to this...

    MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -bind_at_load"  ./configure etc etc etc etc.

    This actually leads to a universal binary for php... <shrug> overkill but it worked and Apache loaded the PHP module.

    My co-worker Harry pointed out that the dyld errors might have been the result of x64/x32 incompatibility as well. It turns out he was right and since our goal was to be able to update apache, php, etc with Software Update (since the client will be responsible for that) I put back the stock libphp5.so. Re-did --enable-dbase=shared, THAT loaded and I was back to getting ODBTP working.

    To get ODBTP working I had to do two things... One... I changed the Mac OS section of the Makefile to read as such...

    # MacOS X
    CFLAGS=-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp -O2 -Wall -fPIC -fno-common $(MODULE_CFLAGS)
    LINK=$(CC) -bundle -flat_namespace -undefined suppress

    MACOSX_DEPLOYMENT_TARGET=10.5
    CCFLAGS=-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe
    CXXFLAGS=-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe
    LDFLAGS=-arch ppc -arch ppc64 -arch i386 -arch x86_64 -bind_at_load

    When I did just that I was getting "Invalid Response" errors but the module did load.

    Then I /finally/ found the README.64bitOS file and tried that. For me it didn't work... I had to add the line to php_odbtp.h in the php/ext folder. (which I added right under the #define PHP_ODBTP_H (since the other fix went under #define _ODBTP_H_ in the odbtp.h file)

    THEN I finally had a working php_odbtp.so that both loaded and fetched data AND that worked with the stock PHP 5.2.4 installation on Leopard.

    Now this is a distallation of the better part of two days struggle of someone that can compile but doesn't really do C/C++/etc programming, so some things may be extranious and some might be that I did it in a certain order (starting/stopping services, rebooting, etc) but that's how I was able to get it to work.

    I don't really have a place to post files for download but I'd be glad to email the resulting php_odbtp.so to anyone that wants to post it themselves.

    I hope this helps someone... Thanks for providing this project. ODBTP has made our lives SO much easier.

    Matt Neimeyer

     
    • mneimeyer

      mneimeyer - 2008-03-14

      Forgot to mention... the dyld: NSLinkModule() error was seen by running php -v at a command line. A web page trying to load the modules showed something cryptic about being unable to load the extension and not much else.

      Also... the error that Apache x64 gave trying to load PHP x32 was along the lines of (based on my Google history)

         Cannot load libphp5.so into server no suitable image found mach-o wrong architecture.

      Using file on the php_odbtp.so that works for me results in:

         php_odbtp.so: Mach-O universal binary with 4 architectures
         php_odbtp.so (for architecture ppc7400): Mach-O bundle ppc
         php_odbtp.so (for architecture ppc64):   Mach-O 64-bit bundle ppc64
         php_odbtp.so (for architecture i386):    Mach-O bundle i386
         php_odbtp.so (for architecture x86_64):  Mach-O 64-bit bundle x86_64

      Matt

       
    • Robert Twitty

      Robert Twitty - 2008-03-14

      Hi Matt

      Thanks for providing this info.

      -- bob

       

Log in to post a comment.