Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errors in dns.c while compiling PHP #1

Open
ClosetGeek-Git opened this issue Feb 7, 2017 · 7 comments
Open

errors in dns.c while compiling PHP #1

ClosetGeek-Git opened this issue Feb 7, 2017 · 7 comments

Comments

@ClosetGeek-Git
Copy link

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
Copy link
Member

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
Copy link
Author

ClosetGeek-Git commented Feb 9, 2017

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
Copy link
Member

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

@ClosetGeek-Git
Copy link
Author

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
Copy link
Member

  • Move the #undef statement to different places and try. Try using Crystax maybe ?
  • I first used Google NDK and it compiled. Then I used Crystax.

@ClosetGeek-Git
Copy link
Author

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
Copy link
Member

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

  • My dns.c file

  • Output of uname -a : Linux simsu-veriton-series 4.4.0-31-generic #50-Ubuntu SMP Wed Jul 13 00:06:14 UTC 2016 i686 athlon i686 GNU/Linux

    I'm using Xubuntu 16.04 (32 bit)

  • NDK : crystax-ndk-10.3.2

  • My Makefile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants