centos6.8上编译安装PHP7.4.12时遇到的问题解决思路

1 篇文章 0 订阅

每个人的环境不同,所以在这里不穷举所有的例子了,仅和大家分享一下遇到类似问题时的解题思路。

1 configure时遇到报sqlite3、onig等依赖库有缺失,使用yum install安装后再重新configure,如过还提示无法找到这些库,请仔细看提示,根据提示设置环境变量即可。下面是设置环境变量的例子:

#how to fix the oniguruma dependency issue
export ONIG_CFLAGS="/usr/bin/onig-config"
export ONIG_LIBS="/usr/lib64/"

2 make时遇到undefined reference to `sqlite3_xxxx...这种错误,假如能确定之前已经安装过sqlite3。则可以检查Makefile文件

在其中添加上-lsqlite3.(如果你缺少其它,按照自己实际缺少的去修改Makefile)

EXTRA_LIBS = -lcrypt -lcrypt -lrt -lbz2 -lrt -lm -ldl -lrt -lxml2 -lssl -lcrypto -lz -lcurl -lxml2 -lssl -lcrypto -lxml2 -lxml2 -lcrypt -lxml2 -lxml2 -lxml2 -lxml2 -lxslt -lz -lm -lxml2 -lexslt -lxslt -lz -lm -lgcrypt -ldl -lgpg-error -lxml2 -lz -lssl -lcrypto -lcrypt -lsqlite3 -lonig

3 已经安装了sqlite3 3.27版本,但是在编译时报 udefined reference to 'sqlite3_stmt_readonly'

ext/sqlite3/.libs/sqlite3.o: In function `zim_sqlite3stmt_readOnly':
/home/ivan/php7.4/php-7.4.12/ext/sqlite3/sqlite3.c:1515: undefined reference to `sqlite3_stmt_readonly'
ext/pdo_sqlite/.libs/sqlite_statement.o: In function `pdo_sqlite_stmt_get_attribute':
/home/ivan/php7.4/php-7.4.12/ext/pdo_sqlite/sqlite_statement.c:406: undefined reference to `sqlite3_stmt_readonly'

上面的提示的意思是:sqlite3.o和sqlite_statement.o中的sqlite3_stmt_readonly函数需要依赖其它的库但无法找到。见下面。

nm ext/sqlite3/.libs/sqlite3.o | grep sqlite3_stmt_readonly
                 U sqlite3_stmt_readonly
nm ext/pdo_sqlite/.libs/sqlite_statement.o | grep sqlite3_stmt_readonly
                 U sqlite3_stmt_readonly

使用ldd命令查看可能的依赖关系。

[root@VM-0-14-centos php-7.4.12]# ldd ext/sqlite3/.libs/sqlite3.o
ldd: warning: you do not have execution permission for `ext/sqlite3/.libs/sqlite3.o'
        not a dynamic executable

这是因为版本不兼容导致,先检查.o文件,可以看到是64位的。

[root@VM-0-14-centos php-7.4.12]# readelf -h ext/sqlite3/.libs/sqlite3.o
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              REL (Relocatable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          0 (bytes into file)
  Start of section headers:          134496 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           0 (bytes)
  Number of program headers:         0
  Size of section headers:           64 (bytes)
  Number of section headers:         40
  Section header string table index: 37

 

 

重新编译直到报错。然后再用ldd查看sqlite3.o的依赖库。

yum -y install libstdc++.i686

make clean

make

 

 

 

使用nm去查看符号表,结论是目前已经安装的libsqlite3.so中没有sqlite3_stmt_readonly方法。:(


[root@VM-0-14-centos php-7.4.12]# nm -oD /usr/lib64/libsqlite3.so | grep sqlite3_stmt_readonly
[root@VM-0-14-centos php-7.4.12]#

问题到这里其实并没有解决,在php7.4中make时仍然会报找不到sqlite3_stmt_readonly

但从编译sqlite3的源代码中却是可以找到这个API,说明源码没问题,可能安装出问题。

[root@VM-0-14-centos sqlite-autoconf-3270200]# find ./ -name "*.h" | xargs grep "sqlite3_stmt_readonly"
./sqlite3ext.h:#define sqlite3_stmt_readonly          sqlite3_api->stmt_readonly
./sqlite3.h:** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if
./sqlite3.h:** directly, sqlite3_stmt_readonly() would still return true.)^
./sqlite3.h:** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true,
./sqlite3.h:** sqlite3_stmt_readonly() to return true since, while those statements
./sqlite3.h:** ^The sqlite3_stmt_readonly() interface returns true for [BEGIN] since
./sqlite3.h:** sqlite3_stmt_readonly() returns false for those commands.
./sqlite3.h:SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);

检查当前的sqlite3的安装

[root@VM-0-14-centos sqlite-autoconf-3270200]# whereis sqlite3
sqlite3: /usr/bin/sqlite3 /usr/local/bin/sqlite3 /usr/include/sqlite3.h /usr/share/man/man1/sqlite3.1.gz

vim /usr/include/sqlite3.h
可以看到其实安装的还是3.6.20版本的sqlite,而sqlite的官方文档里面可以搜索到changelist表明sqlite3_stmt_readonly是3.7才加入的。

**
** <blockquote><pre>
** SQLITE_VERSION_NUMBER = W*1000000 + X*1000 + Y
** </pre></blockquote>
**
** Since version 3.6.18, SQLite source code has been stored in the
** <a href="http://www.fossil-scm.org/">fossil configuration management
** system</a>.  The SQLITE_SOURCE_ID
** macro is a string which identifies a particular check-in of SQLite
** within its configuration management system.  The string contains the
** date and time of the check-in (UTC) and an SHA1 hash of the entire
** source tree.
**
** See also: [sqlite3_libversion()],
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
**
** Requirements: [H10011] [H10014]
*/
#define SQLITE_VERSION        "3.6.20"
#define SQLITE_VERSION_NUMBER 3006020
#define SQLITE_SOURCE_ID      "2009-11-04 13:30:02 eb7a544fe49d1626bacecfe53ddc03fe082e3243"

接下去,用3.27版本的sqlite3.h替换/usr/include/下面的sqlite3.h

make clean

make

然而问题依旧,看来替换这个sqlite3.h并不能解决问题,或者说这个文件在这个位置只是结果,不是原因。查一下当前安装的所有的libsqlite3.so

[root@VM-0-14-centos php-7.4.12]# find / -name "*sqlite3.so*"
/home/ivan/download/sqlite-autoconf-3270200/.libs/libsqlite3.so.0
/home/ivan/download/sqlite-autoconf-3270200/.libs/libsqlite3.so
/home/ivan/download/sqlite-autoconf-3270200/.libs/libsqlite3.so.0.8.6
/usr/lib64/libsqlite3.so.0
/usr/lib64/libsqlite3.so
/usr/lib64/python2.6/lib-dynload/_sqlite3.so
/usr/lib64/libsqlite3.so.0.8.6
/usr/local/lib/libsqlite3.so.0
/usr/local/lib/libsqlite3.so
/usr/local/lib/libsqlite3.so.0.8.6

用nm逐个去检查,可以看到/usr/local/lib/下的sqlite3.so都包含了接口。而/usr/lib64/下的则没有。

[root@VM-0-14-centos php-7.4.12]# nm -oD /usr/local/lib/libsqlite3.so.0 | grep sqlite3_stmt_readonly
/usr/local/lib/libsqlite3.so.0:0000000000013330 T sqlite3_stmt_readonly
[root@VM-0-14-centos php-7.4.12]# nm -oD /usr/local/lib/libsqlite3.so | grep sqlite3_stmt_readonly
/usr/local/lib/libsqlite3.so:0000000000013330 T sqlite3_stmt_readonly
[root@VM-0-14-centos php-7.4.12]# nm -oD /usr/local/lib/libsqlite3.so.0.8.6 | grep sqlite3_stmt_readonly
/usr/local/lib/libsqlite3.so.0.8.6:0000000000013330 T sqlite3_stmt_readonly

[root@VM-0-14-centos php-7.4.12]# nm -oD /usr/lib64/libsqlite3.so.0.8.6 | grep sqlite3_stmt_readonly
[root@VM-0-14-centos php-7.4.12]# nm -oD /usr/lib64/libsqlite3.so.0 | grep sqlite3_stmt_readonly
[root@VM-0-14-centos php-7.4.12]# nm -oD /usr/lib64/libsqlite3.so | grep sqlite3_stmt_readonly

 

有问题欢迎交流,可以加我微信:blockchain-killer

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值