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

标签 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

当我使用以下选项尝试 ./configure for php7 时,我收到一条错误消息 configure: error: mcrypt.h not found。请重新安装 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

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

最佳答案

让我们看看这个错误在 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

我们可以忽略 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
...

现在一切都清楚了。如果 $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

到:

--with-mcrypt=/home/mybin

关于php - linux 正确标志传递 gcc mcrypt.h 位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35891777/

相关文章:

php - Base64 编码 PHP 生成的图像,而不将图像写入磁盘

php - 动态网站的 "recommended"是多少种语言?

javascript - 单击链接后刷新 div _blank

c++ - 跨 TU 的类模板重载

c++ - shared_ptr 赋值符号隐式转换

c - _start 是否调用我的程序的主函数和其他基本设置函数?

php - 如何通过php在mysql数据库上运行cron作业

c++ - 这个声明是什么意思?

linux - bash shell 脚本,从文本文件中获取两列数据,并使用带有两个变量的 for 循环

linux - 了解 Unix 所有者和 chmod 777