goodspb / pdlib

PHP extension for Dlib.
MIT License
71 stars 19 forks source link

Building on Alpine fails (configure: error: pkg-config not found) #17

Closed agboom closed 4 years ago

agboom commented 4 years ago

I'm trying to build pdlib in an Alpine Docker image (including the dlib dependency), but I'm stuck on the ./configure step.

Here is the output:

Cloning into 'pdlib'...
Configuring for:
PHP Api Version:         20180731
Zend Module Api No:      20180731
Zend Extension Api No:   320180731
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php7 -I/usr/include/php7/main -I/usr/include/php7/TSRM -I/usr/include/php7/Zend -I/usr/include/php7/ext -I/usr/include/php7/ext/date/lib
checking for PHP extension directory... /usr/lib/php7/modules
checking for PHP installed headers prefix... /usr/include/php7
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking for pdlib support... yes, shared
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking how to run the C++ preprocessor... g++ -E
checking for pkg-config... configure: error: pkg-config not found
make: *** No targets specified and no makefile found.  Stop.
make: *** No rule to make target 'install'.  Stop.
The command '/bin/sh -c git clone https://github.com/goodspb/pdlib.git   ; cd pdlib   ; phpize   ; ./configure --enable-debug   ; make   ; make DESTDIR=/pdlib-install install' returned a non-zero code: 2

And here is the Dockerfile to reproduce:

FROM alpine

RUN apk update && apk add bash vim git

# DLib https://github.com/goodspb/pdlib#dependencies
RUN apk add cmake make gcc libc-dev g++ openblas-dev libx11-dev

RUN git clone https://github.com/davisking/dlib.git \
  ; cd dlib/dlib \
  ; mkdir build \
  ; cd build \
  ; cmake -DBUILD_SHARED_LIBS=ON .. \
  ; make \
  ; make DESTDIR=/dlib-install install \
  ; make install

# https://github.com/goodspb/pdlib#installation
RUN apk add php7-dev

RUN git clone https://github.com/goodspb/pdlib.git \
  ; cd pdlib \
  ; phpize \
  ; ./configure --enable-debug \ # <-- this is the step that fails
  ; make \
  ; make DESTDIR=/pdlib-install install

Any idea what could be going wrong?

matiasdelellis commented 4 years ago

Hi @agboom Remove '--enable-debug' option.. I remember that this option failed me before..

stalker314314 commented 4 years ago

I started watching this repo, I completely missed this question. Hopefully, we will be notified on next one:)

Happyfeet01 commented 4 years ago

It fails for me also at the configure step. (Ubuntu 18.04)

agboom commented 4 years ago

Thanks for your suggestion @matiasdelellis, I removed the option, but sadly it still gives the same error (configure: error: pkg-config not found).

Happyfeet01 commented 4 years ago

apt install pkg-config

works for me

agboom commented 4 years ago

That's great! Sadly it doesn't work in the Alpine container. pkg-config is installed correctly and can be found in the path. Looking at the configure file, the problem is that pkgconfig --exists dlib-1 yields false.

The part in configure that fails is around line 4675:

  if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists dlib-1; then
     if $PKG_CONFIG dlib-1 --atleast-version 19.00; then
        LIBDLIB_CFLAGS=`$PKG_CONFIG dlib-1 --cflags`
        LIBDLIB_LIBDIR=`$PKG_CONFIG dlib-1 --libs`
        LIBDLIB_VERSON=`$PKG_CONFIG dlib-1 --modversion`
        { $as_echo "$as_me:${as_lineno-$LINENO}: result: from pkgconfig: dlib version $LIBDLIB_VERSON" >&5
$as_echo "from pkgconfig: dlib version $LIBDLIB_VERSON" >&6; }
     else
        as_fn_error $? "system dlib is too old: version 19.00 required" "$LINENO" 5
     fi
  else
     if test -x "$PKG_CONFIG"; then echo "HI"; fi # <-- test to see if pkg-config is detected
     as_fn_error $? "pkg-config not found" "$LINENO" 5
  fi
agboom commented 4 years ago

I found the problem: pkg-config was looking in the wrong places. Setting PKG_CONFIG_PATH=/dlib-install/usr/local/lib64/pkgconfig/ before running ./configure solves this.

Snake883 commented 4 years ago

Should this be added to the Installation Instructions (README.md - https://github.com/goodspb/pdlib/blob/master/README.md#installation)?

apt install pkg-config

stalker314314 commented 4 years ago

Unfortunately, @goodspb (author) is unavailable. I am discussing with @matiasdelellis to fork this and continue from there.

Claudio140 commented 4 years ago

I found the problem: pkg-config was looking in the wrong places. Setting PKG_CONFIG_PATH=/dlib-install/usr/local/lib64/pkgconfig/ before running ./configure solves this.

Sadly, this did not help for me. I use a Fedora server which only has pkgconf package, not pkg-config, but these two should basically be the same. What can I do?

eliliam commented 4 years ago

+1 on my end. Ubuntu 18.04 server and I have pkg-config installed from apt(I have actually used it from the cli myself, so I know it works) but configure says it is not found.

agboom commented 4 years ago

PKG_CONFIG_PATH=/dlib-install/usr/local/lib64/pkgconfig/ was pretty specific for my system. Did you find out where the pkgconfig directory was located on your system?

Claudio140 commented 4 years ago

I found it, seems like I'm simply not used to non-default paths. Thanks for your hint. It was in /usr/local/lib64/pkgconfig

hdp2101 commented 4 years ago

Hello

I found the pkgconfig as you showed the location, but can you tell me where to change this path of pkgconfig. still i see same error of pkg-config not found after i type PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig/ in terminal and when i run ./configure command.

If possible please give some idea about this error.

Thank you Ashampoo_Snap_2020 05 12_15h51m00s_001_