Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows下怎么编译安装gmssl-php扩展,生成dll文件啊 #9

Open
Mr-Wang-Ya opened this issue Apr 23, 2024 · 2 comments
Open

Comments

@Mr-Wang-Ya
Copy link

No description provided.

@Mr-Wang-Ya Mr-Wang-Ya changed the title windows下怎么编译安装php扩展啊 windows下怎么编译安装gmssl-php扩展,生成dll文件啊 Apr 23, 2024
@ccboxers
Copy link

大佬,解决了吗?怎么安装呀

@denept
Copy link

denept commented Dec 19, 2024

编译windows gmssl.dll,以php-7.3.33为例,原程序用vs2017编译

方式一
1.启动php-sdk-binary-tools-php-sdk-2.2.0中对应php版本的vs*.bat。提前安装号对应版本的build工具例如:vs_BuildTools_2017.exe
例如出现以下内容表示启动成功:
[vcvarsall.bat] Environment initialized for: 'x64'
PHP SDK 2.2.0
OS architecture: 64-bit
Build architecture: 64-bit
Visual C++: 14.16.27051.0
PHP-SDK path: G:\php-sdk-binary-tools-php-sdk-2.2.0
G:\php-sdk-binary-tools-php-sdk-2.2.0
$

2.执行 phpsdk_buildtree phpdev 新建一个phpdev编译目录
3.把php源码放入同级deps目录的目录中
4.运行phpsdk_deps -u 下载依赖包(可以忽略)
5.进入源码/ext 找到 ext_skel.php,建立一个扩展 php ext_skel.php --ext gmssl gmssl是扩展的名称
然后把下载的GmSSL-PHP-main扩展源码文件内容覆盖进 ext/gmssl目录里
6.buildconf
7.运行 configure --help 查看命令是否生成成功
8.执行 configure --disable-all --enable-cli --enable-gmssl=shared --enable-gmssl=shared表示编译php_gmssl.dll文件
9.在Makefile文件的LIBS=kernel32.lib... 后面添加 gmssl.lib 这个是GmSSL-3.1.1-win64.exe安装的文件
10.在windows中增加环境变量INCLUDE 指向gmssl的include目录,LIB指向gmssl的lib目录。也可以加到nmake的环境变量目录中:
查看nmake lib路径
nmake /p | findstr "LIB"
例如:Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\lib
11.执行nmake进行编译
12.拷贝编译好的php_gmssl.dll到php的ext目录中,拷贝gmssl.dll文件到php主程序目录中。gmssl.dll这个是GmSSL-3.1.1-win64.exe安装的文件

方式二直接用vs编译
1.打开vs选择 文件->新建-》从现有代码创建项目
选择创建 visualC++项目
项目名称:php_gmssl,勾选“将文件从这些文件夹添加到项目中”。
选择“使用 visual studio”,项目类型“动态链接库(DLL)项目”
2.把解决方案配置改为Release,平台选择“x64”
3.打开“项目”->“属性”->“c/c++”->“常规”->“附加包含目录”,新增:
G:\php-sdk-binary-tools-php-sdk-2.2.0\phpdev\vc15\x64\php-7.3.33
G:\php-sdk-binary-tools-php-sdk-2.2.0\phpdev\vc15\x64\php-7.3.33\main
G:\php-sdk-binary-tools-php-sdk-2.2.0\phpdev\vc15\x64\php-7.3.33\TSRM
G:\php-sdk-binary-tools-php-sdk-2.2.0\phpdev\vc15\x64\php-7.3.33\Zend

3.“c/c++”->“预处理器”->“预处理器定义”,新增:
GMSSL_EXPORTS
ZEND_DEBUG=0
PHP_EXTENSION
PHP_WIN32
ZEND_WIN32
HAVE_GMSSL=1 GMSSL为扩展程序名称
COMPILE_DL_GMSSL
ZTS

4.“链接器”->“输入”->“附加依赖项”,新增:
G:\php-sdk-binary-tools-php-sdk-2.2.0\phpdev\vc15\x64\php-7.3.33\x64\Release_TS\php7ts.lib php\dev也有这个文件
C:\Program Files\GmSSL\lib\gmssl.lib

5.“配置属性”->“常规”->“平台工具集”。选择“visual studio 2017(v141)”

6.编译后得到php_gmssl.dll文件。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants