Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

linux correct flag to pass gcc mcrypt.h location

I have compiled libmcrypt from source to /home/mybin/... with the following confirmed as the location of the needed files.

/home/mybin/include/mcrypt.h
/home/mybin/include/mutils/mcrypt.h
/home/mybin/lib/libmcrypt.so ...> 4.4.8
/home/mybin/bin/libmcrypt-config

When I try a ./configure for php7 using the below options, I get an error message configure: error: mcrypt.h not found. Please reinstall libmcrypt.

What flags am I using incorrectly to tell gcc to look in the ../include directory for mcrypt.h

./configure \
CC=/home/mybin/bin/gcc \
CPPFLAGS="-I/home/mybin/include" \
LDFLAGS="-L/home/mybin/lib" \
LIBS="-lmcrypt" \
--prefix=/home/_cgi/php7 \
--bindir=/home/mybin/bin \
--libdir=/home/mybin/lib \
--includedir=/home/mybin/include \
--with-mcrypt=/home/mybin/lib

from the configure --help I get

Some influential environment variables:
  CC          C compiler command
  CFLAGS      C compiler flags
  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
              nonstandard directory <lib dir>
  LIBS        libraries to pass to the linker, e.g. -l<library>
  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
              you have headers in a nonstandard directory <include dir>
  CPP         C preprocessor
  YACC        The `Yet Another Compiler Compiler' implementation to use.
              Defaults to the first program found out of: `bison -y', `byacc',
              `yacc'.
  YFLAGS      The list of arguments that will be passed by default to $YACC.
              This script will default YFLAGS to the empty string to avoid a
              default value of `-d' given by some make applications.
  CXX         C++ compiler command
  CXXFLAGS    C++ compiler flags
  CXXCPP      C++ preprocessor

  Fine tuning of the installation directories:
  --bindir=DIR            user executables [EPREFIX/bin]
  --sbindir=DIR           system admin executables [EPREFIX/sbin]
  --libexecdir=DIR        program executables [EPREFIX/libexec]
  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
  --libdir=DIR            object code libraries [EPREFIX/lib]
  --includedir=DIR        C header files [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
  --infodir=DIR           info documentation [DATAROOTDIR/info]
  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
  --mandir=DIR            man documentation [DATAROOTDIR/man]
  --docdir=DIR            documentation root [DATAROOTDIR/doc/PACKAGE]
  --htmldir=DIR           html documentation [DOCDIR]
  --dvidir=DIR            dvi documentation [DOCDIR]
  --pdfdir=DIR            pdf documentation [DOCDIR]
  --psdir=DIR             ps documentation [DOCDIR]

--with-mcrypt=DIR       Include mcrypt support
like image 706
art vanderlay Avatar asked Jan 07 '23 12:01

art vanderlay


1 Answers

Let's see where this error comes from in the php7 source tree:

php-7.0.4$ grep -r 'mcrypt.h not found. Please reinstall libmcrypt'
ext/mcrypt/config.m4:    AC_MSG_ERROR(mcrypt.h not found. Please reinstall libmcrypt.)
configure:    as_fn_error $? "mcrypt.h not found. Please reinstall libmcrypt." "$LINENO" 5

We can ignore configure since it's a generated file, so it's from that m4 macro ext/mcrypt/config.m4. Let's look at the context:

...
if test "$PHP_MCRYPT" != "no"; then
  for i in $PHP_MCRYPT /usr/local /usr; do
    test -f $i/include/mcrypt.h && MCRYPT_DIR=$i && break
  done

  if test -z "$MCRYPT_DIR"; then
    AC_MSG_ERROR(mcrypt.h not found. Please reinstall libmcrypt.)
  fi
...

Now all becomes clear. If $PHP_MCRYPT isn't "no" then its the value of DIR as per --with-mcrypt[=DIR], i.e. a directory path or nothing.

If it's nothing then mcrypt.h is looked for in:

  • /usr/local/include (libmcrypt was installed by a default make install)
  • /usr/include (libmcrypt was installed by the distro package manager)

If it's not nothing then mcrypt.h is additionally (and for preference) looked for in:

  • $PHP_MCRYPT/include (libmcrypt was installed by a non-default make install to $PHP_MCRYPT)

So if you specify --with-mcrypt=DIR, then DIR should be your installation prefix for libmcrypt, not the directory containing libmcrypt.so.

So your solution is, change:

--with-mcrypt=/home/mybin/lib

to:

--with-mcrypt=/home/mybin
like image 84
Mike Kinghan Avatar answered Jan 15 '23 01:01

Mike Kinghan