LobbyOS / android-standalone

Lobby Android Standalone
https://lobby.subinsb.com
Apache License 2.0
7 stars 1 forks source link

errors in dns.c while compiling PHP #1

Open ClosetGeek-Git opened 7 years ago

ClosetGeek-Git commented 7 years ago

Compiling using Ubuntu and new NDK. Complaining about unrecognized vars/functions (HEAD, TX, etc). I get this issue every way that I try compiling PHP for Android and I know that it's due to how NDK/Bionic handles DNS compared to glibc but was hoping your build process would fix the issue. Am I doing something wrong? let me know if your not familiar with this issue and I'll post a copy of the result compiler.

subins2000 commented 7 years ago

Read this : https://github.com/LobbyOS/android-standalone/blob/master/compile/php/README.md

It has the solution to the dns.c problem

ClosetGeek-Git commented 7 years ago

Includes seem to be defined between line 23 and line 119 in current ext/standard/dns.c. I'm assuming #undef HAVE_RES_NSEARCH on line 120 should work?

subins2000 commented 7 years ago

I added it here after including dns.h : https://github.com/php/php-src/blob/master/ext/standard/dns.c#L59

ClosetGeek-Git commented 7 years ago

Still not working for some reason. Here's the outcome

/home/jason/git-reps/android-standalone/compile/php/src/ext/standard/dns.c:328:2: error: unknown type name 'HEADER'
  HEADER qb1;
  ^
/home/jason/git-reps/android-standalone/compile/php/src/ext/standard/dns.c: In function 'zif_dns_check_record':
/home/jason/git-reps/android-standalone/compile/php/src/ext/standard/dns.c:363:13: error: 'T_MX' undeclared (first use in this function)
  int type = T_MX, i;
             ^
/home/jason/git-reps/android-standalone/compile/php/src/ext/standard/dns.c:363:13: note: each undeclared identifier is reported only once for each function it appears in
/home/jason/git-reps/android-standalone/compile/php/src/ext/standard/dns.c:383:45: error: 'T_A' undeclared (first use in this function)
   if (!strcasecmp("A",     rectype)) type = T_A;
                                             ^
In file included from /home/jason/git-reps/android-standalone/compile/php/src/ext/standard/dns.c:77:0:
/home/jason/git-reps/android-standalone/compile/php/src/ext/standard/dns.c:416:39: error: 'C_IN' undeclared (first use in this function)
  i = php_dns_search(handle, hostname, C_IN, type, ans, sizeof(ans));
                                       ^
/home/jason/git-reps/android-standalone/compile/php/src/ext/standard/php_dns.h:41:22: note: in definition of macro 'php_dns_search'
    res_search(dname, class, type, answer, anslen)
                      ^
/home/jason/git-reps/android-standalone/compile/php/src/ext/standard/dns.c: In function 'php_parserr':
/home/jason/git-reps/android-standalone/compile/php/src/ext/standard/dns.c:459:23: error: 'T_ANY' undeclared (first use in this function)
  if (type_to_fetch != T_ANY && type != type_to_fetch) {
                       ^
/home/jason/git-reps/android-standalone/compile/php/src/ext/standard/dns.c: In function 'zif_dns_get_record':
/home/jason/git-reps/android-standalone/compile/php/src/ext/standard/dns.c:783:2: error: unknown type name 'HEADER'
  HEADER *hp;
  ^
In file included from /home/jason/git-reps/android-standalone/compile/php/src/ext/standard/dns.c:77:0:
/home/jason/git-reps/android-standalone/compile/php/src/ext/standard/dns.c:910:41: error: 'C_IN' undeclared (first use in this function)
    n = php_dns_search(handle, hostname, C_IN, type_to_fetch, answer.qb2, sizeof answer);
                                         ^
/home/jason/git-reps/android-standalone/compile/php/src/ext/standard/php_dns.h:41:22: note: in definition of macro 'php_dns_search'
    res_search(dname, class, type, answer, anslen)
                      ^
/home/jason/git-reps/android-standalone/compile/php/src/ext/standard/dns.c:936:10: error: 'HEADER' undeclared (first use in this function)
    hp = (HEADER *)&answer;
          ^
/home/jason/git-reps/android-standalone/compile/php/src/ext/standard/dns.c:936:18: error: expected expression before ')' token
    hp = (HEADER *)&answer;
                  ^
In file included from /home/jason/android-ndk-r13b/platforms/android-16/arch-arm/usr/include/endian.h:31:0,
                 from /home/jason/android-ndk-r13b/platforms/android-16/arch-arm/usr/include/sys/stat.h:36,
                 from /home/jason/git-reps/android-standalone/compile/php/src/Zend/zend_stream.h:28,
                 from /home/jason/git-reps/android-standalone/compile/php/src/Zend/zend.h:41,
                 from /home/jason/git-reps/android-standalone/compile/php/src/main/php.h:35,
                 from /home/jason/git-reps/android-standalone/compile/php/src/ext/standard/dns.c:24:
/home/jason/git-reps/android-standalone/compile/php/src/ext/standard/dns.c:937:17: error: request for member 'qdcount' in something not a structure or union
    qd = ntohs(hp->qdcount);
                 ^
/home/jason/git-reps/android-standalone/compile/php/src/ext/standard/dns.c:938:17: error: request for member 'ancount' in something not a structure or union
    an = ntohs(hp->ancount);
                 ^
/home/jason/git-reps/android-standalone/compile/php/src/ext/standard/dns.c:939:17: error: request for member 'nscount' in something not a structure or union
    ns = ntohs(hp->nscount);
                 ^
/home/jason/git-reps/android-standalone/compile/php/src/ext/standard/dns.c:940:17: error: request for member 'arcount' in something not a structure or union
    ar = ntohs(hp->arcount);
                 ^
/home/jason/git-reps/android-standalone/compile/php/src/ext/standard/dns.c: In function 'zif_dns_get_mx':
/home/jason/git-reps/android-standalone/compile/php/src/ext/standard/dns.c:1006:2: error: unknown type name 'HEADER'
  HEADER *hp;
  ^
In file included from /home/jason/git-reps/android-standalone/compile/php/src/ext/standard/dns.c:77:0:
/home/jason/git-reps/android-standalone/compile/php/src/ext/standard/dns.c:1044:39: error: 'C_IN' undeclared (first use in this function)
  i = php_dns_search(handle, hostname, C_IN, DNS_T_MX, (u_char *)&ans, sizeof(ans));
                                       ^
/home/jason/git-reps/android-standalone/compile/php/src/ext/standard/php_dns.h:41:22: note: in definition of macro 'php_dns_search'
    res_search(dname, class, type, answer, anslen)
                      ^
/home/jason/git-reps/android-standalone/compile/php/src/ext/standard/dns.c:1051:8: error: 'HEADER' undeclared (first use in this function)
  hp = (HEADER *)&ans;
        ^
/home/jason/git-reps/android-standalone/compile/php/src/ext/standard/dns.c:1051:16: error: expected expression before ')' token
  hp = (HEADER *)&ans;
                ^
In file included from /home/jason/android-ndk-r13b/platforms/android-16/arch-arm/usr/include/endian.h:31:0,
                 from /home/jason/android-ndk-r13b/platforms/android-16/arch-arm/usr/include/sys/stat.h:36,
                 from /home/jason/git-reps/android-standalone/compile/php/src/Zend/zend_stream.h:28,
                 from /home/jason/git-reps/android-standalone/compile/php/src/Zend/zend.h:41,
                 from /home/jason/git-reps/android-standalone/compile/php/src/main/php.h:35,
                 from /home/jason/git-reps/android-standalone/compile/php/src/ext/standard/dns.c:24:
/home/jason/git-reps/android-standalone/compile/php/src/ext/standard/dns.c:1054:37: error: request for member 'qdcount' in something not a structure or union
  for (qdc = ntohs((unsigned short)hp->qdcount); qdc--; cp += i + QFIXEDSZ) {
                                     ^
/home/jason/git-reps/android-standalone/compile/php/src/ext/standard/dns.c:1060:34: error: request for member 'ancount' in something not a structure or union
  count = ntohs((unsigned short)hp->ancount);
                                  ^
Makefile:558: recipe for target 'ext/standard/dns.lo' failed
make: *** [ext/standard/dns.lo] Error 1
jason@dev:~/git-reps/android-standalone/compile$

Testing on a fresh install of Ubuntu Server 16.04.1 LTS. Fresh copy of android-ndk-r13b-linux-x86_64, fresh copy of php-7.1.1. Not building with any extensions at this time, just vanilla PHP with --disable-all to minimize complications. Here's the modifications that I've done to auto-compile.sh to remove fluff for now:


set -e

compileDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

function setenv(){
  . $compileDir/setenv.sh
}

function php(){
  cd $compileDir/php/src

  . $compileDir/setenv.sh

  export CFLAGS="$CFLAGS -pie -fPIE -fpic -fPIC -ldl -lc -lsupc++ -lstdc++ -lstlport_static"

  ./configure --host=$TARGET \
    --disable-all \
    --with-pic \
    --with-config-file-path=php.ini --with-config-file-scan-dir=. \
    --enable-cli --disable-cgi \
    --prefix="$(`echo realpath '../output'`)"

  sed -i -e 's~-I/usr/include~-I${SYSROOT}/usr/include~g' Makefile
  sed -i -e 's~-L/usr/lib/i386-linux-gnu~-L${SYSROOT}/usr/lib~g' Makefile

  make clean
  make
  make install

  cd ..

  mkdir -p php php/extensions
  cp ./output/bin/php ./php/php-cli
  cp ./php-wrapper ./php/php

  chrpath --delete php/php-cli php/extensions/*

  mkdir -p php-22
  cp ./php/* ./php-22 -r
  ../android-elf-cleaner/output/aec ./php-22/php-cli ./php-22/extensions/*
}

if [ -z $1 ]; then
  php
else
  $1
fi

Also, I noticed that setenv.sh has includes for crystax. Are you using Google's Android NDK or CrystaX NDK?

Thanks

subins2000 commented 7 years ago
ClosetGeek-Git commented 7 years ago

Nope, not working. I've spent around 30 hours trying to get this to build to the same result. Please let me know if there is more information that I can give you to help resolve this. What Linux distro are you using to successfully compile this? What NDK version? Can you post a copy of the PHP Makefile from the php/SRC dir of your working build tree, and a copy of the working dns.c file that you use? It has to be something simple, but I'm at a loss at this point.

subins2000 commented 7 years ago

I understand the frustation. I also spent more than 30 hours for compiling PHP.