linux正确的标志传递gcc mcrypt.h的位置

art*_*lay 3 php c++ linux gcc php-7

我已经libmcrypt从源代码编译到/home/mybin/...以下确认为所需文件的位置.

/home/mybin/include/mcrypt.h
/home/mybin/include/mutils/mcrypt.h
/home/mybin/lib/libmcrypt.so ...> 4.4.8
/home/mybin/bin/libmcrypt-config
Run Code Online (Sandbox Code Playgroud)

当我使用以下选项尝试./configure for php7时,我收到一条错误消息 configure: error: mcrypt.h not found. Please reinstall libmcrypt.

我错误地使用什么标志告诉gcc在../include目录中查找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
Run Code Online (Sandbox Code Playgroud)

configure --help我得到

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
Run Code Online (Sandbox Code Playgroud)

Mik*_*han 7

让我们看看这个错误来自php7源代码树:

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
Run Code Online (Sandbox Code Playgroud)

我们可以忽略configure它,因为它是一个生成的文件,所以它来自那个m4ext/mcrypt/config.m4.我们来看看上下文:

...
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
...
Run Code Online (Sandbox Code Playgroud)

现在一切都变得清晰.如果$PHP_MCRYPT不是"否",则其价值DIR--with-mcrypt[=DIR],即目录路径或没有.

如果它什么都没有,那么请mcrypt.h查找:

  • /usr/local/include(libmcrypt默认安装make install)
  • /usr/include(libmcrypt由发行包管理器安装)

如果它不是什么都没有,那么mcrypt.h另外(并且优先)寻找:

  • $PHP_MCRYPT/include(libmcrypt由非默认安装make install$PHP_MCRYPT)

因此,如果您指定--with-mcrypt=DIR,那么DIR应该是您的安装前缀 libmcrypt,而不是包含的目录 libmcrypt.so.

所以你的解决方案是,改变:

--with-mcrypt=/home/mybin/lib
Run Code Online (Sandbox Code Playgroud)

至:

--with-mcrypt=/home/mybin
Run Code Online (Sandbox Code Playgroud)

  • 谢谢您,我认为这是我迄今为止获得的最佳答案。内容清晰,具有描述性,最重要的是没有谦逊的暗示。我尝试了几种选项组合,并且--with-mcrypt = / home / mybin工作,但是也使用了--with-libdir = DIR导致失败。删除`--with-libdir`可使另一个`--with-xxx`像您描述的那样工作,包括我的其他问题http://stackoverflow.com/questions/35879203/linux-php-7-配置错误,请重新安装readline,我无法找到readline。Thx Art。 (2认同)