赞
踩
环境:
CentOS Linux release 7.3.1611 (Core)
PHP 5.4.16
安装php、查看php版本
# yum install php php-devel
# php -v
- [root@localhost hello]# cat hello.c
-
- #include <stdio.h>
-
- int hello_add (int a, int b)
-
- {
-
- return a+b;
-
- }
生成动态库:
# gcc -fPIC -shared -o libhello.so hello.c
# cp libhello.so /usr/local/lib // 把生成的链接库放到指定的地址
# echo /usr/local/lib > /etc/ld.so.conf.d/local.conf //把库地址写入到配置文件中
# ldconfig // 用此命令,使刚才写的配置文件生效
对so文件进行测。
- [root@localhost hello]# cat hello-test.c
-
- #include <stdio.h>
-
- int main()
-
- {
-
- int a = 4, b = 6;
-
- printf("%d\n", hello_add(a,b));
-
- return 0;
-
- }
# gcc hello-test.c
# ./a.out
1. 下载与系统安装的同一版本的php源码, 这里选择php 5.4.16版本:
2. 进入php-5.4.16/ext/ 目录下,使用ext_skel生成扩展骨架: 即生成名为hello的模块。
# cd php-5.4.16/ext
# ./ext_skel --extname=hello
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。