microsoft / msphpsql

Microsoft Drivers for PHP for SQL Server
MIT License
1.8k stars 374 forks source link

Error installing on macOs ARM #1386

Closed sirio3mil closed 2 years ago

sirio3mil commented 2 years ago

Please check the FAQ (frequently-asked questions) first. If you have other questions or something to report, please address the following (skipping questions might delay our responses):

PHP version
PHP 8.1.5 (cli) (built: Apr 16 2022 00:03:52) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.5, Copyright (c) Zend Technologies with Zend OPcache v8.1.5, Copyright (c), by Zend Technologies

PHP SQLSRV or PDO_SQLSRV version
Installing using pecl

Client operating system
macOS Monterrey 12.3.1 M1

Problem description
sudo CXXFLAGS="-I/opt/homebrew/opt/unixodbc/include/" LDFLAGS="-L/opt/homebrew/lib/" pecl install pdo_sqlsrv

Build process completed successfully Installing '/opt/homebrew/Cellar/php/8.1.5/pecl/20210902/pdo_sqlsrv.so'

Warning: mkdir(): File exists in System.php on line 294 PHP Warning: mkdir(): File exists in /opt/homebrew/Cellar/php/8.1.5/share/php/pear/System.php on line 294

Warning: mkdir(): File exists in /opt/homebrew/Cellar/php/8.1.5/share/php/pear/System.php on line 294 ERROR: failed to mkdir /opt/homebrew/Cellar/php/8.1.5/pecl/20210902

Expected behavior and actual behavior
Should install sqlsrv driver and see it in php -m

Repro code or steps to reproduce sudo CXXFLAGS="-I/opt/homebrew/opt/unixodbc/include/" LDFLAGS="-L/opt/homebrew/lib/" pecl install pdo_sqlsrv

absci commented 2 years ago

Could you check your ODBC driver version, see if it's >= 17.8?

sirio3mil commented 2 years ago

microsoft/mssql-release/msodbcsql18: stable 18.0.1.1

Now the error is following


In file included from /private/tmp/pear/temp/sqlsrv/shared/typedefs_for_linux.h:23:
/private/tmp/pear/temp/sqlsrv/shared/xplat.h:30:10: fatal error: 'sql.h' file not found
#include <sql.h>
         ^~~~~~~
1 error generated.
make: *** [conn.lo] Error 1
ERROR: `make' failed
absci commented 2 years ago

Looks like you're missing sql.h or it's not in the right place. What's the output for find / -name sql.h?

sirio3mil commented 2 years ago

That was my mistake, I didnt use CXXFLAGS="-I/opt/homebrew/opt/unixodbc/include/" LDFLAGS="-L/opt/homebrew/lib/"

Now I get the original error again


Build complete.
Don't forget to run 'make test'.

running: make INSTALL_ROOT="/private/tmp/pear/temp/pear-build-rootOSN8HK/install-pdo_sqlsrv-5.10.0" install
Installing shared extensions:     /private/tmp/pear/temp/pear-build-rootOSN8HK/install-pdo_sqlsrv-5.10.0/opt/homebrew/Cellar/php/8.1.5/pecl/20210902/
running: find "/private/tmp/pear/temp/pear-build-rootOSN8HK/install-pdo_sqlsrv-5.10.0" | xargs ls -dils
2296091   0 drwxr-xr-x  3 root  wheel      96 10 may 11:12 /private/tmp/pear/temp/pear-build-rootOSN8HK/install-pdo_sqlsrv-5.10.0
2296574   0 drwxr-xr-x  3 root  wheel      96 10 may 11:12 /private/tmp/pear/temp/pear-build-rootOSN8HK/install-pdo_sqlsrv-5.10.0/opt
2296575   0 drwxr-xr-x  3 root  wheel      96 10 may 11:12 /private/tmp/pear/temp/pear-build-rootOSN8HK/install-pdo_sqlsrv-5.10.0/opt/homebrew
2296576   0 drwxr-xr-x  3 root  wheel      96 10 may 11:12 /private/tmp/pear/temp/pear-build-rootOSN8HK/install-pdo_sqlsrv-5.10.0/opt/homebrew/Cellar
2296577   0 drwxr-xr-x  3 root  wheel      96 10 may 11:12 /private/tmp/pear/temp/pear-build-rootOSN8HK/install-pdo_sqlsrv-5.10.0/opt/homebrew/Cellar/php
2296578   0 drwxr-xr-x  3 root  wheel      96 10 may 11:12 /private/tmp/pear/temp/pear-build-rootOSN8HK/install-pdo_sqlsrv-5.10.0/opt/homebrew/Cellar/php/8.1.5
2296579   0 drwxr-xr-x  3 root  wheel      96 10 may 11:12 /private/tmp/pear/temp/pear-build-rootOSN8HK/install-pdo_sqlsrv-5.10.0/opt/homebrew/Cellar/php/8.1.5/pecl
2296580   0 drwxr-xr-x  3 root  wheel      96 10 may 11:12 /private/tmp/pear/temp/pear-build-rootOSN8HK/install-pdo_sqlsrv-5.10.0/opt/homebrew/Cellar/php/8.1.5/pecl/20210902
2296581 672 -rwxr-xr-x  1 root  wheel  343098 10 may 11:12 /private/tmp/pear/temp/pear-build-rootOSN8HK/install-pdo_sqlsrv-5.10.0/opt/homebrew/Cellar/php/8.1.5/pecl/20210902/pdo_sqlsrv.so

Build process completed successfully
Installing '/opt/homebrew/Cellar/php/8.1.5/pecl/20210902/pdo_sqlsrv.so'

Warning: mkdir(): File exists in System.php on line 294
PHP Warning:  mkdir(): File exists in /opt/homebrew/Cellar/php/8.1.5/share/php/pear/System.php on line 294

Warning: mkdir(): File exists in /opt/homebrew/Cellar/php/8.1.5/share/php/pear/System.php on line 294
ERROR: failed to mkdir /opt/homebrew/Cellar/php/8.1.5/pecl/20210902
absci commented 2 years ago

I think you can try delete the folder 20210902 from /opt/homebrew/Cellar/php/8.1.5/pecl/. The build is completed, pecl encountered some error when copying the file.

sirio3mil commented 1 year ago

The problem are the pointers

Folder /opt/homebrew/Cellar/php/8.2.6

lrwxr-xr-x 1 admin admin 26 16 may 16:02 pecl -> /opt/homebrew/lib/php/pecl

It must be /opt/homebrew/lib/php, and also change php.ini whith correct extension_dir