RubixML / Tensor

A library and extension that provides objects for scientific computing in PHP.
https://rubixml.com
MIT License
223 stars 27 forks source link

PECL Windows Build Fails (Missing Dependencies on Build Server) #22

Open P2T opened 3 years ago

P2T commented 3 years ago

All versions fail to compile

fatal error C1083: Cannot open include file: 'cblas.h': No such file or directory

See https://windows.php.net/downloads/pecl/releases/tensor/

andrewdalpino commented 3 years ago

Thank you very much @P2T we'll try to figure this out

mlocati commented 3 years ago

I think that the cause is a missing dependency, but I know absolutely nothing about how the pecl website builds Windows binaries, and how additional dependencies can be configured. My first thought is asking @cmb69

cmb69 commented 3 years ago

It seems this extension requires several libraries, but these dependencies are not checked during configuration on Windows (in config.w32). These checks would fail for PECL builds, though, since these libs are not available at https://windows.php.net/downloads/pecl/deps/. I'll see what I can do.

andrewdalpino commented 3 years ago

Thank you @cmb69! We appreciate the help - let us know what we can do on our end!

Kabingeran commented 2 years ago

Not installed on Docker php:8.0.12-fpm-alpine3.14 Has anyone had this problem?

mlocati commented 2 years ago

@Kabingeran try with https://github.com/mlocati/docker-php-extension-installer

Kabingeran commented 2 years ago

The instructions say what should be installed like this pecl install tensor https://github.com/RubixML/Tensor#readme

mlocati commented 2 years ago

What's the error you are having?

Kabingeran commented 2 years ago

Thank you. The problems was solved by installing the dependencies

mlocati commented 2 years ago

You need to install a couple of system libraries (for example like this), but it's much easier to use https://github.com/mlocati/docker-php-extension-installer

P2T commented 2 years ago

It seems this extension requires several libraries, but these dependencies are not checked during configuration on Windows (in config.w32). These checks would fail for PECL builds, though, since these libs are not available at https://windows.php.net/downloads/pecl/deps/. I'll see what I can do.

Can this problem be also solved ?

cmb69 commented 2 years ago

Can this problem be also solved ?

I tried to build OpenBLAS on Windows a while ago, but failed miserably. I have not been able to find usable prebuilt binaries either. Any pointer would be appreciated.

mlocati commented 2 years ago

@cmb69 can't we use the lib/dll/.h files that come from assets attached to https://github.com/xianyi/OpenBLAS/releases ?

cmb69 commented 2 years ago

@mlocati, thanks for the hint! That seems to work for the vs16 builds, but apparently hangs for the vc15 builds (likely it is because they used VS 2019 for compiling/linking, but maybe I screwed something up). I need to check out the details tomorrow, and will then do a snapshot build of the latest PECL package, so that it can be tested before I do a release build.

cmb69 commented 2 years ago

This is super ugly! There's no way to link a v142 built lib with v141, so we can't use these binaries for PHP < 8.0.0. Furthermore, PECL builds won't work even for PHP ≥ 8.0.0, because we're using the 16.9 toolset, but those binaries have been built with the 16.8 toolset, and PECL builds do a full in-tree build. So without other OpenBLAS binaries, we can only have phpize builds of tensor for PHP ≥ 8.0.0 on Windows.

Oh, and this only works, if we patch lapack.h, because MSVC doesn't support the _Complex keyword, and defining respective macros as explained in the header would skip the inclusion of complex.h.

Anyhow, I've made the modified packages available as pecl/deps, and submitted PR #24, which allows for phpize builds. You can get prebuilt Windows packages; please test these, but do not use them in production!

P2T commented 2 years ago

I've tried them on Windows 10, PHP 8.0.10, it seems to be OK. Thank you.

cmb69 commented 2 years ago

Replying to https://github.com/RubixML/Tensor/pull/24#issuecomment-991824993 here, because that PR discussion has been locked by the bot.

I'm afraid there is no documentation regarding the configuration on Windows. It is basically a partial port of GNU autoconf to JScript running on the Windows scripting host. Most of the GNU autoconf macro replacements are defined in confutils.js; the main script to build the configuration is buildconf.js.

Anyhow, the patch in PR #24 is about checking for the OpenBLAS library actually being available, and to let the build fail otherwise. More importantly, though, CHECK_LIB also adds the library to the libraries to link against, and CHECK_HEADER_ADD_INCLUDE adds the headers to the include path. If this is not done (especially the CHECK_LIB), the build inevitably fails due to missing symbols from libopenblas.lib. All that is basically the Windows counterpart of

https://github.com/RubixML/Tensor/blob/ebef5142e03e8d7d2806c7dcb786c00bfd2793e7/ext/config.m4#L7-L9

Note that the PHP Windows buildsystem does not use pkg-config.

BTW, I think this ticket can be closed after PR #24 has been merged.

andrewdalpino commented 2 years ago

Oh sorry about that, I'll have to find a way to allow comments on merged PRs. Thanks for the explanation, it really helps alot! We still need to figure a way to patch the config.w32 file after Zephir compiles it. It shoudn't be too hard now that I have a better idea as to what's going on.

ncavare commented 2 years ago

Hello has anyone been able to compile the extension for windows?

federicoemartinez commented 2 years ago

Hi! What is the status of this issue? Is it possible to get the extension compiled for windows? Thanks!

federicoemartinez commented 2 years ago

I've managed to build it for php 7.4 nts x64 for windows: https://github.com/federicoemartinez/Tensor/releases/tag/3.0.1 I don't know if I can help you somehow so you can build it again.

takielias commented 1 year ago

I've managed to build it for php 7.4 nts x64 for windows: https://github.com/federicoemartinez/Tensor/releases/tag/3.0.1 I don't know if I can help you somehow so you can build it again.

This does not work for me.

image

federicoemartinez commented 1 year ago

I've managed to build it for php 7.4 nts x64 for windows: https://github.com/federicoemartinez/Tensor/releases/tag/3.0.1 I don't know if I can help you somehow so you can build it again.

This does not work for me.

image

Where did you put libopenblas.dll? Try placing it in the same directory as php.exe if you put it in the ext directory.

takielias commented 1 year ago

I've managed to build it for php 7.4 nts x64 for windows: https://github.com/federicoemartinez/Tensor/releases/tag/3.0.1 I don't know if I can help you somehow so you can build it again.

This does not work for me. image

Where did you put libopenblas.dll? Try placing it in the same directory as php.exe if you put it in the ext directory.

image I did but facing same issue.

takielias commented 1 year ago

I'm using ts version of php 7.4. Is it an issue?

takielias commented 1 year ago

@federicoemartinez Thanks a lot. solved the issue by using nts version of PHP 7.4. Could you please make a ts version of the tensor build for windows please?

federicoemartinez commented 1 year ago

@federicoemartinez Thanks a lot. solved the issue by using nts version of PHP 7.4. Could you please make a ts version of the tensor build for windows please?

I'll try, but I'm going on vacations right now so it will have to wait.

takielias commented 1 year ago

@federicoemartinez Thanks a lot. solved the issue by using nts version of PHP 7.4. Could you please make a ts version of the tensor build for windows please?

I'll try, but I'm going on vacations right now so it will have to wait.

That's great. Waiting for your ts release.

takielias commented 1 year ago

@federicoemartinez I have tried several time but could not use the .dll of PHP 8.1 (nts). It does not show any error. Is it not ready? image

takielias commented 1 year ago

@federicoemartinez Thanks a lot. solved the issue by using nts version of PHP 7.4. Could you please make a ts version of the tensor build for windows please?

I'll try, but I'm going on vacations right now so it will have to wait.

Hello @federicoemartinez Could you please make a ts version?

jb-lopez commented 1 year ago

Hey @takielias I'm not sure if you ever got it to build. It took me many tries and a few days, but I did get it to work.

https://github.com/jb-lopez/php-extensions-windows/releases/tag/Tensor

takielias commented 1 year ago

Hey @takielias I'm not sure if you ever got it to build. It took me many tries and a few days, but I did get it to work.

https://github.com/jb-lopez/php-extensions-windows/releases/tag/Tensor

@jb-lopez

That's a great help. Thanks a lot. Great contribution. I really appreciate your work.