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 使用 Cygwin 构建 swool-cli 不成功。 #569

Open
vkviyu opened this issue Mar 14, 2024 · 18 comments
Open

windows 使用 Cygwin 构建 swool-cli 不成功。 #569

vkviyu opened this issue Mar 14, 2024 · 18 comments

Comments

@vkviyu
Copy link

vkviyu commented Mar 14, 2024

Snipaste_2024-03-14_14-39-00

构建步骤是按照文档所描述的以下五步所进行的:
bash ./sapi/scripts/cygwin/install-re2c.sh
bash ./sapi/scripts/cygwin/cygwin-config-ext.sh
bash ./sapi/scripts/cygwin/cygwin-config.sh
bash ./sapi/scripts/cygwin/cygwin-build.sh
bash ./sapi/scripts/cygwin/cygwin-archive.sh

libtool: unrecognized option -export-dynamic' Try libtool --help' for more information.
make: *** [Makefile:258: bin/swoole-cli] Error 1

在 cygwin-build.sh 阶段,会报这个错误:libtool: unrecognized option `-export-dynamic'

同时如果在 config.sh 中启用了 opcache :--enable-opcache ,那么在 cygwin-config.sh 这个阶段也会报错找不到共享内存,不支持 sysvipc 之类的错误。

使用 build-native-cli 的版本进行构建,可以在最后构建出一个 php.exe ,但是在最后也会提示:
sapi/cli/php_cli_server.o sapi/cli/ps_title.o sapi/cli/php_cli_process_title.o -lrt -lm -o sapi/cli/php
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: warning: --export-dynamic is not supported for PE+ targets, did you mean --export-all-symbols?

然后点击构建出的 php.exe ,使用 php -m 就会提示:”无法定位程序输入点 setproctitle 于动态链接库 php.exe 上“。

因为我需要使用 oci8 或者说 pdo_oci ,还不得不直接在 windows 环境上直接使用。所以只能自己构建。
我想问一下官方对于 php-cli-cygwin 版本构建时也出现过这种问题吗。还是说我的 cygwin 少了一些必要的库没有安装吗?或者说安装过程中少了一些步骤吗?

@jingjingxyk
Copy link
Contributor

jingjingxyk commented Mar 14, 2024

第一个问题: libtool: unrecognized option-export-dynamic' 执行 make clean重新构建 ,全称应该是--export-dynamic`

第二个问题: https://github.com/swoole/swoole-cli/actions/runs/8262323228/job/22601412406#step:10:1606 只是警告

可以先下载已经构建好的版本试试

https://github.com/swoole/swoole-cli/releases/tag/v5.1.1.0

https://github.com/swoole/swoole-cli/releases/tag/v5.1.1.0

https://github.com/swoole/swoole-cli/actions/runs/8262323228/job/22601412406#step:10:1606

@jingjingxyk
Copy link
Contributor

jingjingxyk commented Mar 14, 2024

oci8 或者 pdo_oci 待验证

@vkviyu
Copy link
Author

vkviyu commented Mar 14, 2024

@jingjingxyk

第一个问题: libtool: unrecognized option-export-dynamic' 执行 make clean重新构建 ,全称应该是--export-dynamic`

第二个问题: https://github.com/swoole/swoole-cli/actions/runs/8262323228/job/22601412406#step:10:1606 只是警告

可以先下载已经构建好的版本试试

https://github.com/swoole/swoole-cli/releases/tag/v5.1.1.0

https://github.com/swoole/swoole-cli/releases/tag/v5.1.1.0

https://github.com/swoole/swoole-cli/actions/runs/8262323228/job/22601412406#step:10:1606

第一个问题。我 make clean 之后重新构建,还是会发生同样的报错。
还有就是,构建 build-naive-php 这个版本,在 cygwin-build.sh 阶段,在弹出这个警告之后:
Snipaste_2024-03-14_17-19-45
构建过程好像就终止了(还是正常结束了)?
但是这 build 出来的程序目录是这样的:
image
这是没有构建完全吗还是说没有进行构建?。如果我 php.exe -m 就会报错弹窗:
Snipaste_2024-03-14_17-23-08
翻了很多文档,好像对于 windows 上 swoole-cli 的构建很少。

@jingjingxyk
Copy link
Contributor

第一个问题,我再试试。

第二个问题: 执行打包看看,然后在测试看看

@jingjingxyk
Copy link
Contributor

jingjingxyk commented Mar 14, 2024

我购买了弹性云服务器,再一次验证测试 问题一,结果如下:
image
image

问题二: 构建结果如下

image

@jingjingxyk
Copy link
Contributor

@jingjingxyk

第一个问题: libtool: unrecognized option-export-dynamic' 执行 make clean重新构建 ,全称应该是--export-dynamic`
第二个问题: https://github.com/swoole/swoole-cli/actions/runs/8262323228/job/22601412406#step:10:1606 只是警告
可以先下载已经构建好的版本试试
https://github.com/swoole/swoole-cli/releases/tag/v5.1.1.0
https://github.com/swoole/swoole-cli/releases/tag/v5.1.1.0
https://github.com/swoole/swoole-cli/actions/runs/8262323228/job/22601412406#step:10:1606

第一个问题。我 make clean 之后重新构建,还是会发生同样的报错。 还有就是,构建 build-naive-php 这个版本,在 cygwin-build.sh 阶段,在弹出这个警告之后: Snipaste_2024-03-14_17-19-45 构建过程好像就终止了(还是正常结束了)? 但是这 build 出来的程序目录是这样的: image 这是没有构建完全吗还是说没有进行构建?。如果我 php.exe -m 就会报错弹窗: Snipaste_2024-03-14_17-23-08 翻了很多文档,好像对于 windows 上 swoole-cli 的构建很少。

构建结果是正常的,构建出来的是命令行程序,不应该用双击打开程序。

@vkviyu
Copy link
Author

vkviyu commented Mar 15, 2024

@jingjingxyk 感谢你的帮助。我这边直接编译已经能够成功了,之前的问题应该是库版本或者库缺失的问题,通过 quickstart 下面的快速安装脚本,已经解决这个问题了。我现在在尝试想要用 OCI8 或者 pdo_oci 。

@vkviyu
Copy link
Author

vkviyu commented Mar 15, 2024

@jingjingxyk 请问现在 swoole-cli 的编译还不支持 oci8 和 pdo_oci 吗?还是说仅是 Cygwin 的 swoole-cli 的编译不支持 oci8 和 pdo_oci 。我在 cygwin-config.sh 这个脚本中指定配置参数 --with-oci8 和 --with-pdo-oci 。如下图:
Snipaste_2024-03-15_12-10-59
然后在 cygwin-build.sh 阶段,最后会输出:Extension 'swoole' not present 。应该是和这两个参数有关系吧?
Snipaste_2024-03-15_12-11-23
同时在这个 php -m 的输出里,显然有很多模块还没有被构建进来,应该是构建提前结束了?使用打包的这个 sh 脚本,也不会产生文件夹。
Snipaste_2024-03-15_12-19-52

@jingjingxyk
Copy link
Contributor

jingjingxyk commented Mar 15, 2024

@jingjingxyk 请问现在 swoole-cli 的编译还不支持 oci8 和 pdo_oci 吗?还是说仅是 Cygwin 的 swoole-cli 的编译不支持 oci8 和 pdo_oci 。我在 cygwin-config.sh 这个脚本中指定配置参数 --with-oci8 和 --with-pdo-oci 。如下图: Snipaste_2024-03-15_12-10-59 然后在 cygwin-build.sh 阶段,最后会输出:Extension 'swoole' not present 。应该是和这两个参数有关系吧? Snipaste_2024-03-15_12-11-23 同时在这个 php -m 的输出里,显然有很多模块还没有被构建进来,应该是构建提前结束了?使用打包的这个 sh 脚本,也不会产生文件夹。 Snipaste_2024-03-15_12-19-52

  1. 支持 oci8 和 pdo_oci 目前还没有验证过,待编译验证(做法: 下载Extension for Oracle Database扩展,扩展下载好了,把扩展源码拷贝到 ext 目录,即可进行编译验证。建议用experiment 分支来验证
  2. Extension 'swoole' not present 出现这个是因为,swoole 源码不存在,需要拉取一下。 (拉取子模块git submodule update --init
  3. 通过截图,你只是构建了默认php ,再次执行bash ./sapi/scripts/cygwin/cygwin-config.sh 注意看预处理提示

@vkviyu
Copy link
Author

vkviyu commented Mar 15, 2024

@jingjingxyk 我发现为什么之构建了一部分 PHP 扩展了,原来是因为 cygwin-config.sh 这个文件 configure 中的参数项行与行之间不能有空行,也就是回车,回车被当作了结束,所以只 configure 了一部分参数项,正好启用 swoole 扩展的参数项就是在空行后面,导致没有被 configure 进去。也就导致输出了 swoole 扩展不存在这个问题。
image
这些配置项行与行之间不能有空行,这么简单的问题我刚注意到。十分感谢你的帮助。

@vkviyu
Copy link
Author

vkviyu commented Mar 15, 2024

@jingjingxyk pdo-oci 好像找不到 sdk 下 include 目录的路径,oci8 在 configure 阶段 check for pcntl 会检测失败

instantclient 目录,如下图所示,包含了 basc 目录和 sdk 目录:

image-20240315200012811

--with-pdo-oci 参数,直接书写 Oracle Instant Client 目录路径:--with-pdo-oci=/cygdrive/f/instantclient ,如下图所示:

image-20240315195911145

在 configure 阶段会报错输出以下内容:

checking Oracle OCI support for PDO... yes
checking Oracle Install-Dir... /cygdrive/f/instantclient :/cygdrive/f/instantclient:
checking if that is sane... yes
checking Oracle version... configure: error: Oracle-OCI needed libraries not found under /cygdrive/f/instantclient

如下图所示:

image-20240315200655914

--with-pdo-oci 参数,在 Oracle Instant Client 目录路径前面加上 instantclient, 即:

--with-pdo-oci=instantclient,/cygdrive/f/instantclient ,如下图所示:

![image-20240315200542354](Cygwin 构建 swoole-cli 的 pdo-oci md.assets/image-20240315200542354.png)

在 configure 阶段会报错输出以下内容:

checking Oracle OCI support for PDO... yes
checking Oracle Install-Dir... instantclient,/cygdrive/f/instantclient :instantclient,/cygdrive/f/instantclient:
checking if that is sane... yes
checking for oci.h... configure: error: I'm too dumb to figure out where the include dir is in your instant client install

如下图所示:

image-20240315200542354

我不知道哪种写法是正确的,第一种:--with-pdo-oci=/cygdrive/f/instantclient ,还是第二种:--with-pdo-oci=instantclient,/cygdrive/f/instantclient 。这两种写法我都设置了 ORACLE_HOME 环境变量为 instantclient 目录的路径,但好像都没有作用。我感觉第二种写法是正确的,但是不知道为什么会找不到 include 目录。

如果使用 oci8 扩展,在 configure 阶段的 check for foek 时,就会显示 noconfigure: error: pcntl: fork() not supported by this platform 。使用 pdo-oci 扩展的话这个检测可以过去,就是后面那样找不到 include dir。

image-20240315201202867

@jingjingxyk
Copy link
Contributor

jingjingxyk commented Mar 15, 2024

@jingjingxyk pdo-oci 好像找不到 sdk 下 include 目录的路径,oci8 在 configure 阶段 check for pcntl 会检测失败

instantclient 目录,如下图所示,包含了 basc 目录和 sdk 目录:

image-20240315200012811

--with-pdo-oci 参数,直接书写 Oracle Instant Client 目录路径:--with-pdo-oci=/cygdrive/f/instantclient ,如下图所示:

image-20240315195911145

在 configure 阶段会报错输出以下内容:

checking Oracle OCI support for PDO... yes
checking Oracle Install-Dir... /cygdrive/f/instantclient :/cygdrive/f/instantclient:
checking if that is sane... yes
checking Oracle version... configure: error: Oracle-OCI needed libraries not found under /cygdrive/f/instantclient

如下图所示:

image-20240315200655914

--with-pdo-oci 参数,在 Oracle Instant Client 目录路径前面加上 instantclient, 即:

--with-pdo-oci=instantclient,/cygdrive/f/instantclient ,如下图所示:

![image-20240315200542354](Cygwin 构建 swoole-cli 的 pdo-oci md.assets/image-20240315200542354.png)

在 configure 阶段会报错输出以下内容:

checking Oracle OCI support for PDO... yes
checking Oracle Install-Dir... instantclient,/cygdrive/f/instantclient :instantclient,/cygdrive/f/instantclient:
checking if that is sane... yes
checking for oci.h... configure: error: I'm too dumb to figure out where the include dir is in your instant client install

如下图所示:

image-20240315200542354

我不知道哪种写法是正确的,第一种:--with-pdo-oci=/cygdrive/f/instantclient ,还是第二种:--with-pdo-oci=instantclient,/cygdrive/f/instantclient 。这两种写法我都设置了 ORACLE_HOME 环境变量为 instantclient 目录的路径,但好像都没有作用。我感觉第二种写法是正确的,但是不知道为什么会找不到 include 目录。

如果使用 oci8 扩展,在 configure 阶段的 check for foek 时,就会显示 noconfigure: error: pcntl: fork() not supported by this platform 。使用 pdo-oci 扩展的话这个检测可以过去,就是后面那样找不到 include dir。

image-20240315201202867

写法是否正确,进入扩展目录看描述,看例子就能判断,是否正确 。参考: https://www.php.net/pdo_ocihttps://www.php.net/manual/en/oci8.installation.php

方法一: 应该找到 cygwin 环境下对应的 instantclient库 ,这里没有搜到https://cygwin.com/cgi-bin2/package-grep.cgi?grep=instantclient
方法二: cygwin 环境下编译 instantclient ,无源码https://www.oracle.com/cn/database/technologies/instant-client/downloads.html
方法三: 使用odbc , https://www.oracle.com/cn/database/technologies/releasenote-odbc-ic.html ; cygwin 环境中源码编译unixODBC库。 https://github.com/lurcher/unixODBC/blob/master/README.CYGWIN

使用那种,我也不确定,需要实验验证。

@vkviyu
Copy link
Author

vkviyu commented Mar 16, 2024

@jingjingxyk
之前所说的那个找不到 include dir 的报错已经解决了。原因是因为 pecl 上面提供的 pdo_oci 扩展很久没有更新了,相比于 php 源码中提供的 pdo_oci 扩展落后很多个版本,所以扩展中的导致 config.m4 文件和 Oracle Instant Client 目录结构没有对应上。

在新版的 php 当中,--with-pdo-oci=instantclient,/path/to/client 。这个配置项这样配置应该是没有问题的。
image-20240316132949356

昨天看了一晚上 pdo_oci 扩展的 config.m4 文件,得出了上面的结论。

现在好像目录都能找到了但是又出现了新的问题,如下所示:

checking whether to enable PDO support... yes
checking for MySQL support for PDO... yes
checking for the location of libz... no
checking for MySQL UNIX socket location... no
checking for PDO includes... /cygdrive/f/last/swoole-cli/ext
checking Oracle OCI support for PDO... yes
checking Oracle Install-Dir... instantclient,/cygdrive/f/instantclient
checking if that is sane... yes
checking size of long... (cached) 8
checking if we're at 64-bit platform... yes
checking Oracle version... 21.1
checking for oci.h... /cygdrive/f/instantclient/sdk/include
checking for OCIEnvCreate in -lclntsh... no
checking for OCIEnvNlsCreate in -lclntsh... no
checking for OCIStmtFetch2 in -lclntsh... no
checking for OCILobRead2 in -lclntsh... no
checking for PDO includes... (cached) /cygdrive/f/last/swoole-cli/ext
checking for PostgreSQL support for PDO... no
checking for PostgreSQL support... no
checking for phar archive support... yes
checking for phar openssl support... yes
checking whether to enable POSIX-like functions... yes
checking for sys/mkdev.h... no
checking for sys/sysmacros.h... yes
checking for seteuid... no
checking for setegid... no
checking for setsid... no
checking for getsid... no
checking for getpgid... no
checking for ctermid... no
checking for mkfifo... no
checking for mknod... no
checking for setrlimit... no
checking for getrlimit... no
checking for getgroups... no
checking for makedev... no
checking for initgroups... no
checking for getgrgid_r... no
checking for working ttyname_r() implementation... no, posix_ttyname() will be thread-unsafe
checking for utsname.domainname... no
checking for libedit readline replacement... no
checking for readline support... yes
checking for tgetent in -lncurses... no
checking for tgetent in -ltermcap... no
checking for readline in -lreadline... no
configure: error: readline library not found

感觉这一段输出中的:

  • checking for OCIEnvCreate in -lclntsh... no
    checking for OCIEnvNlsCreate in -lclntsh... no
    checking for OCIStmtFetch2 in -lclntsh... no
    checking for OCILobRead2 in -lclntsh... no

这四条信息应该是最后导致错误 readline library not found 产生的原因。

image-20240316124318903

从这段信息来看是我不太确信是因为我环境变量配置的仍然有问题,导致它最终还是没有找到 lclntsh 从而导致报错?;还是说其实 Oracle Instant Client 这个客户端库在 cygwin 上就是不受支持的,哪怕 Cygwin 模拟了一个 linux 的环境同样没有办法直接使用适用于 linux 的 Oracle Instant Client 库?

还有就是之前所说的如果开启 oci8 扩展就会产生 opcache 不支持、pcntl 不支持这两个问题。想用 oci8 应该也是不太可能了。

@jingjingxyk
Copy link
Contributor

jingjingxyk commented Mar 16, 2024

@jingjingxyk 之前所说的那个找不到 include dir 的报错已经解决了。原因是因为 pecl 上面提供的 pdo_oci 扩展很久没有更新了,相比于 php 源码中提供的 pdo_oci 扩展落后很多个版本,所以扩展中的导致 config.m4 文件和 Oracle Instant Client 目录结构没有对应上。

在新版的 php 当中,--with-pdo-oci=instantclient,/path/to/client 。这个配置项这样配置应该是没有问题的。 image-20240316132949356

昨天看了一晚上 pdo_oci 扩展的 config.m4 文件,得出了上面的结论。

现在好像目录都能找到了但是又出现了新的问题,如下所示:

checking whether to enable PDO support... yes
checking for MySQL support for PDO... yes
checking for the location of libz... no
checking for MySQL UNIX socket location... no
checking for PDO includes... /cygdrive/f/last/swoole-cli/ext
checking Oracle OCI support for PDO... yes
checking Oracle Install-Dir... instantclient,/cygdrive/f/instantclient
checking if that is sane... yes
checking size of long... (cached) 8
checking if we're at 64-bit platform... yes
checking Oracle version... 21.1
checking for oci.h... /cygdrive/f/instantclient/sdk/include
checking for OCIEnvCreate in -lclntsh... no
checking for OCIEnvNlsCreate in -lclntsh... no
checking for OCIStmtFetch2 in -lclntsh... no
checking for OCILobRead2 in -lclntsh... no
checking for PDO includes... (cached) /cygdrive/f/last/swoole-cli/ext
checking for PostgreSQL support for PDO... no
checking for PostgreSQL support... no
checking for phar archive support... yes
checking for phar openssl support... yes
checking whether to enable POSIX-like functions... yes
checking for sys/mkdev.h... no
checking for sys/sysmacros.h... yes
checking for seteuid... no
checking for setegid... no
checking for setsid... no
checking for getsid... no
checking for getpgid... no
checking for ctermid... no
checking for mkfifo... no
checking for mknod... no
checking for setrlimit... no
checking for getrlimit... no
checking for getgroups... no
checking for makedev... no
checking for initgroups... no
checking for getgrgid_r... no
checking for working ttyname_r() implementation... no, posix_ttyname() will be thread-unsafe
checking for utsname.domainname... no
checking for libedit readline replacement... no
checking for readline support... yes
checking for tgetent in -lncurses... no
checking for tgetent in -ltermcap... no
checking for readline in -lreadline... no
configure: error: readline library not found

感觉这一段输出中的:

* checking for OCIEnvCreate in -lclntsh... no
  checking for OCIEnvNlsCreate in -lclntsh... no
  checking for OCIStmtFetch2 in -lclntsh... no
  checking for OCILobRead2 in -lclntsh... no

这四条信息应该是最后导致错误 readline library not found 产生的原因。

image-20240316124318903

从这段信息来看是我不太确信是因为我环境变量配置的仍然有问题,导致它最终还是没有找到 lclntsh 从而导致报错?;还是说其实 Oracle Instant Client 这个客户端库在 cygwin 上就是不受支持的,哪怕 Cygwin 模拟了一个 linux 的环境同样没有办法直接使用适用于 linux 的 Oracle Instant Client 库?

还有就是之前所说的如果开启 oci8 扩展就会产生 opcache 不支持、pcntl 不支持这两个问题。想用 oci8 应该也是不太可能了。

需要确认Oracle Instant Client 是否支持cygwin 环境,我在Oracle 官网上没有找到相关信息 https://www.google.com/search?q=Oracle+Instant+Client+for+cygwin+

@vkviyu
Copy link
Author

vkviyu commented Mar 18, 2024

@jingjingxyk
image
如果要创建 pdo_oci 扩展和 oci8 扩展,那么在 sapi/src/builder/extension 创建扩展之后,要在扩展里面指定依赖库之后,然后还需要 library 目录下创建下面这种格式来进行构建吗?
image

@jingjingxyk
Copy link
Contributor

@jingjingxyk image 如果要创建 pdo_oci 扩展和 oci8 扩展,那么在 sapi/src/builder/extension 创建扩展之后,要在扩展里面指定依赖库之后,然后还需要 library 目录下创建下面这种格式来进行构建吗? image

linux 、macos 环境下是需要这样做的,cygwin 环境下不需要

@vkviyu
Copy link
Author

vkviyu commented Mar 18, 2024

@jingjingxyk 我一开始是想用 Cygwin 的。因为它很方便,但是恰巧没有我要用的 pdo_oci 和 oci8 扩展,然后就想办法解决,看了 Cygwin 的构建编译阶段的几个 sh 脚本,Cygwin 下应该是不走 builder 目录下的 extension 和 library ,直接走 ext 目录吧。但是后面就遇到了之前所说的问题。好像在 Cygwin 下只是在 config.sh 中指定 pdo_oci 扩展和 oci8 扩展的 Oracle Instant Client 目录,走不下去。没办法了只能转向 wsl 或者 linux 这种了。结果发现一样的过不了 Oracle Instant Client 这一关,不过好在还有点思路能尝试。还是说在 Cygwin 环境中也需要将 oracle instant client 集成进来,而不能单纯的只是在 config.sh 中的 --with-pdo-oci 这个参数中指定 oracle instant client 库的目录。

@jingjingxyk
Copy link
Contributor

jingjingxyk commented Mar 23, 2024

@vkviyu 真正的问题在于oracle instant client 没有开放源码,官方仅提供可动态加载的二进制库

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

2 participants