cross compile php

This is a discussion on cross compile php within the C Programming forums, part of the General Programming Boards category; Hi im trying to make a cross compile php im having some troubles because i have to compile first this ...

  1. #1
    Registered User
    Join Date
    Jun 2010
    Posts
    18

    cross compile php

    Hi im trying to make a cross compile php im having some troubles because i have to compile first this library:
    i dont know where i should post this trouble, i decided here because im trying with c language

    libxml2-2.6.19
    but when i trying to make it throws me this mistake:

    Code:
    ./.libs/libxml2.so: undefined reference to `gzopen'
    ./.libs/libxml2.so: undefined reference to `gzclose'
    ./.libs/libxml2.so: undefined reference to `deflate'
    ./.libs/libxml2.so: undefined reference to `gzrewind'
    ./.libs/libxml2.so: undefined reference to `gzwrite'
    ./.libs/libxml2.so: undefined reference to `crc32'
    ./.libs/libxml2.so: undefined reference to `deflateEnd'
    ./.libs/libxml2.so: undefined reference to `gzdopen'
    ./.libs/libxml2.so: undefined reference to `deflateInit2_'
    ./.libs/libxml2.so: undefined reference to `gzread'
    collect2: ld returned 1 exit status
    make[2]: *** [xmllint] Error 1
    make[2]: se sale del directorio `/home/felipe/Escritorio/libxml2-2.6.19'
    make[1]: *** [all-recursive] Error 1
    make[1]: se sale del directorio `/home/felipe/Escritorio/libxml2-2.6.19'
    make: *** [all] Error 2
    the code im using to compile it, its this:

    Code:
    export CROSS_COMPILE=arm-none-linux-gnueabi-
    export CC=${CROSS_COMPILE}"gcc"
    export CXX=${CROSS_COMPILE}"g++" 
    ./configure --host=arm-linux --target=arm --prefix=$PWD/install-arm
    i hope you can help me thanks!!

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Looks to me like libxml2 may depend on zlib (I think those are zlib functions anyway). That means if you want to build it from source, you need at least the zlib development headers (maybe you'll need to build zlib too, I dunno much about cross-compiling).
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    Have you looked into Buildroot? What you're attempting to do is possible, but is a real pain in the undercarriage. Buildroot is really cool, though, and can even get you away from glibc (which is really slow and too big for most embedded applications).

  4. #4
    Registered User
    Join Date
    Jun 2010
    Posts
    18
    mk27,

    im starting to think that too (libxml2 depend on zlib) but i found this info:

    Libxml2 does not require any other library, the normal C ANSI API should be sufficient (please report any violation to this rule you may find).

    However if found at configuration time libxml2 will detect and use the following libs:

    * libz : a highly portable and available widely compression library.

    so i think this its like an option, friend the links you send me are very well im going to need them after to study a little more c but i think that they arent going to be useful for me in this moment.

    kennedy,

    long time ago i tried to compiled a web server using build root it made me crazy, i think im so close to do it in this way, im going to try it a little more.

    i found a persons who has a simillar problem. the links its from this page too:

    Library troubles with makefile

    but i dont understand very well his command line maybe you can help me


    THanks for the fast answer

  5. #5
    Registered User
    Join Date
    Jun 2010
    Posts
    18
    hi made somes changes on my command lines:

    Code:
    export CROSS_COMPILE=arm-none-linux-gnueabi-
    export CC=${CROSS_COMPILE}"gcc"
    export CXX=${CROSS_COMPILE}"g++" 
    ./configure --host=arm-linux --target=arm --without-zlib
    --prefix=/home/felipe/libxml
    it doesnt throwsme mistakes but it doesnt create the folder libxml on
    home/felipe


    so.. was it a good compile?


    its a simple doubt but im comfuse help!!

  6. #6
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    Why not build zlib? That is the obvious path to take if you want to muddle through this endeavor. You'll likely need _MORE_ libraries other than just zlib -- which is why I suggested BuildRoot.

  7. #7
    Registered User
    Join Date
    Jun 2010
    Posts
    18
    kennedy im not sure if you are right, because i repeat this instrution:

    export CROSS_COMPILE=arm-none-linux-gnueabi-
    export CC=${CROSS_COMPILE}"gcc"
    export CXX=${CROSS_COMPILE}"g++"
    ./configure --host=arm-linux --target=arm --prefix=/opt/install-arm

    and after that i checked the some information from the output and i note this:

    Code:
    checking how to hardcode library paths into programs... immediate
    checking whether stripping libraries is possible... yes
    appending configuration tag "F77" to libtool
    Checking zlib
    checking zlib.h usability... yes
    checking zlib.h presence... yes
    checking for zlib.h... yes
    checking for gzread in -lz... no
    Checking headers
    checking for dirent.h that defines DIR... yes
    checking for library containing opendir... none required
    checking for ANSI C header files... (cached) yes
    checking fcntl.h usability... yes
    if it can read zlib usability why am i still having that problem??

    i also made a cross compile of zlib following this steps:

    Used version: zlib-1.1.4.tar.gz

    After unpacked the sources change to the source directory:

    # cd zlib-1.1.4

    # CC=arm-linux-gcc \
    ./configure --prefix=/opt

    # make

    # make install prefix=/opt

    it mades me two folders but include and lib , i move that folder to a new folder zlib inside opt folder

    and tried this code:

    Code:
    export CROSS_COMPILE=arm-none-linux-gnueabi-
    export CC=${CROSS_COMPILE}"gcc"
    export CXX=${CROSS_COMPILE}"g++" 
    ./configure --host=arm-linux --target=arm --with-zlib-dir=/opt/zlib --prefix=/opt/install-arm
    
    make
    but the output was the same problem:

    Code:
    ./.libs/libxml2.so: undefined reference to `gzopen'
    ./.libs/libxml2.so: undefined reference to `gzclose'
    ./.libs/libxml2.so: undefined reference to `deflate'
    ./.libs/libxml2.so: undefined reference to `gzrewind'
    ./.libs/libxml2.so: undefined reference to `gzwrite'
    ./.libs/libxml2.so: undefined reference to `crc32'
    ./.libs/libxml2.so: undefined reference to `deflateEnd'
    ./.libs/libxml2.so: undefined reference to `gzdopen'
    ./.libs/libxml2.so: undefined reference to `deflateInit2_'
    ./.libs/libxml2.so: undefined reference to `gzread'
    collect2: ld returned 1 exit status
    make[2]: *** [xmllint] Error 1
    make[2]: se sale del directorio `/home/felipe/Escritorio/libxml2-2.6.19'
    make[1]: *** [all-recursive] Error 1
    make[1]: se sale del directorio `/home/felipe/Escritorio/libxml2-2.6.19'
    make: *** [all] Error 2
    what could be the problem?? HELLLLP!

  8. #8
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    You have to compile the zlib into the TOOLCHAIN library. IE, you'll want to mimic the way the tool chain sees the compiled libraries.

    EXAMPLE:
    Let's say that I have a toolchain compiled into /opt/arm-linux-gcc4.4.3.
    When I build my zlib for that toolchain I have to put the libraries under the lib directory that /opt/arm-linux-gcc4.4.3/usr/bin/arm-unknown-linux-gcc knows -- which is somewhere like /opt/arm-linux-gcc4.4.3/usr/lib.

    You cannot compile these libraries like you normally do. You cannot locate them to /opt and then willie-nillie move them around, you have to put them where they belong under a SYSROOT.

    EDIT: And BTW, I do KNOW I'm right. I've done this several times (It only takes ONCE to know that it is something you don't want to do again -- I've done it three times now -- I hate it when BuildRoot cannot reproduce my filesystem).
    Last edited by Kennedy; 06-15-2010 at 05:20 PM.

  9. #9
    Registered User
    Join Date
    Jun 2010
    Posts
    18
    kennedy,

    Thanks for all your help i think i did what you tell me, the compiler im using its this:
    arm-linux-gcc-4.3.2 when i was installing it i remember this step:

    add this line: PATH=$PATH:/usr/local/arm/4.3.2/bin

    so i compiled zlib with this:

    Code:
    CC=arm-linux-gcc \
    LDSHARED="arm-linux-gcc -shared -Wl,-soname,libz.so.1" \
    ./configure --shared --prefix=/usr/local/arm/4.3.2/bin 
    
    make
    i created me the compile files on that folder

    but after i tried crosscompile libxml it throws me the same mistake, it is making me crazy what else could be?

  10. #10
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    You don't want the prefix to be anything other than /usr -- as /usr is MAGIC. But, there should be something about SYSROOT or INSTALL_PREFIX in the configure/make system.

  11. #11
    Registered User
    Join Date
    Jun 2010
    Posts
    18
    FRiend i think i got the solution i could compile libxml how ever it didnt create me files
    the solution was copy the zlibs compiles files on libc/lib folder of my crosscompiller

    the final configuration i used was this:

    Code:
    export CROSS_COMPILE=arm-none-linux-gnueabi-
    export CC=${CROSS_COMPILE}"gcc"
    export CXX=${CROSS_COMPILE}"g++" 
    ./configure --host=arm-linux --target=arm --prefix=/opt
    why doesnt it create files?? isnt it suppose that it most be create the files where i put on prefix command line? in my case on /opt folder???

  12. #12
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    No. You should ONLY USE /usr AS THE PREFIX!!!!!!!!!

    ONLY USE /usr

    ONLY USE /usr


    ONLY USE /usr


    Have I said this enough yet? When you are cross compiling a library, you need to home the library to /usr since /usr is MAGIC. There should be some keyword like --with-sysroot=<path to gcc libs> or SYSROOT=<path to gcc libs> or INSTALL_PATH=<path to gcc libs> that allows you to install the library under the /usr prefix (which actually puts it in /usr/lib, with support info in /usr/../etc/<something> -- ie, /etc).

    Why do you not listen when I say set --prefix=/usr ??????????

    Keep in mind that your cross compiler is looking for a sysroot with the libraries compiled offset to that sysroot. In other words, when the library is expecting a shared object file at /usr/lib/, the dynamic linker tells it that this is a sysroot compile so prepend <$SYSROOT> to every absolute path.

  13. #13
    Registered User
    Join Date
    Jun 2010
    Posts
    18
    Friend, it seems at last i could do it ejjeej

    i only had to put make install command jejeje

    thanks

  14. #14
    Registered User
    Join Date
    Jun 2010
    Posts
    18
    hi again jejeje

    keneddy forgiveme: i didnt put that i tried what you tell me (prefix = /usr ) but it didnt work

    now that im tring to compile php. it is throwing me this mistake:
    Code:
    cc1: warning: include location "/usr/include" is unsafe for cross-compilation
    /home/felipe/Escritorio/php-5.3.1/ext/standard/basic_functions.c: In function 'zif_getservbyport':
    /home/felipe/Escritorio/php-5.3.1/ext/standard/basic_functions.c:5589: error: invalid 'asm': invalid operand for code 'w'
    make: *** [ext/standard/basic_functions.lo] Error 1
    the code i used was this:

    Code:
    export CROSS_COMPILE=arm-none-linux-gnueabi-
    export CC=${CROSS_COMPILE}"gcc"
    export CXX=${CROSS_COMPILE}"g++" 
    ./configure --host=arm-linux --target=arm --with-libxml-dir=/opt/libxml --prefix=/opt/php

  15. #15
    Registered User
    Join Date
    Jun 2010
    Posts
    18
    hi i change some lines:

    Code:
    export CROSS_COMPILE=arm-none-linux-gnueabi-
    export CC=${CROSS_COMPILE}"gcc"
    export CXX=${CROSS_COMPILE}"g++"
    ./configure --host=arm-linux --target=arm --prefix=/opt/php \
    --disable-short-tags \
    --without-mysql --without-pear --disable-all --disable-short-tags \
    --enable-libxml \
    --with-libxml-dir=/opt/libxml
    but now it is throw me this mistake:

    /home/felipe/Escritorio/php-5.3.1/main/php_ini.c:349: undefined reference to `php_load_extension'
    collect2: ld returned 1 exit status
    make: *** [sapi/cgi/php-cgi] Error 1


    i feel like i am advancing but too slow grrr Thanks for all your help

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Cross compiling with inline assembly
    By TheEngineer in forum C Programming
    Replies: 10
    Last Post: 04-02-2010, 02:21 PM
  2. Help with PHP extension compilation
    By SkinneyEd in forum C++ Programming
    Replies: 1
    Last Post: 01-10-2006, 03:08 PM
  3. header file compile error
    By Unregistered in forum C Programming
    Replies: 5
    Last Post: 02-23-2002, 05:28 AM
  4. Replies: 4
    Last Post: 11-14-2001, 09:28 AM
  5. how do i compile a program that deals w/classes?
    By Shy_girl_311 in forum C++ Programming
    Replies: 5
    Last Post: 11-11-2001, 01:32 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21