Search code examples
linuxcompilationglibc

How can I compile php-cgi binary using a custom glibc for suse enterprise linux out of cygwin?


Pretty straight to the point I think. Is this do-able?

Background: I'm doing this because I need to run php-cgi on suse enterprise 9 and can't get LD_PRELOAD or LD_LIBRARY_PATH to use other-than-system version of glibc.

php-cgi: /lib/tls/libc.so.6: version `GLIBC_2.7' not found

I downloaded 2.7 from here

http://rpmfind.net/linux/rpm2html/search.php?query=libc.so.6(GLIBC_2.7)

more precisely

ftp://rpmfind.net/linux/sourceforge/r/ro/roblinux/64-32_pkg/core/i686/glibc-2.7-2rt.i686.rpm

and unpacked it using rpm2cpio.

I need php-cgi because I can't install php and want to try JavaBridge for running php out of tomcat.


Solution

  • How can I compile php-cgi binary using a custom glibc for suse enterprise linux out of cygwin?

    Pretty straight to the point I think.

    No, a very confused and circuitous question.

    First, cygwin has absolutely nothing to do with your question: it's for running UNIX programs on Windows, which is not at all what you are asking about.

    Second, your question appears to be: "how do I run pre-build php-cgi binary on a system that has older glibc than the one php-cgi has been built on?", and not about compiling anything.

    To that question, the answer is: you can't (easily) -- UNIX systems do not support forward binary compatibility (build on a new system, run on an older one). Only backward compatibility is supported (old dynamically-linked binaries continue to run on newer systems).

    Your best approach is to try to build php-cgi on your system (which would eliminate its dependency on GLIBC_2.7. If you can't, you should still be able to run such a binary against unpacked glibc-2.7 build, if that binary doesn't re-exec itself. The way to do that, assuming you unpacked glibc-2.7 into e.g. /tmp/glibc-2.7 is something like:

    /tmp/glibc-2.7/lib/ld-linux.so.2 --library-path \
        /tmp/glibc-2.7/lib:/lib:/usr/lib \
      /path/to/php-cgi <args>
    

    (The library path above may need some adjustments to make the loader find all the required libraries.)

    Update:

    is it practical to compile stuff for my linux box in cygwin

    It is possible, but significantly more pain then simply compiling on the linux box itself (and so isn't really practical). You appear to lack any reason to want to do that, other than mis-guided belief that cygwin solves all problems.