系统相关
首页 > 系统相关> > php – linux正确标志传递gcc mcrypt.h的位置

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

作者:互联网

我已经将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.请重新安装libmcrypt.

我错误地使用了什么标志告诉gcc查看mcrypt.h的../include目录

./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

从配置–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,因为它是一个生成的文件,所以它来自那个m4
宏ext / 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不是“不”那么它的
根据–with-mcrypt [= DIR]的DIR值,即目录
路径或没有.

如果它什么都没有,那么在mcrypt.h中寻找:

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

如果它不是什么都不是mcrypt.h另外(并且优先)看
for:

> $PHP_MCRYPT / include(libmcrypt由非默认的make install安装到$PHP_MCRYPT)

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

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

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

至:

--with-mcrypt=/home/mybin

标签:c,php,linux,gcc,php-7
来源: https://codeday.me/bug/20190824/1705704.html