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

MacOS Big Sur #1213

Closed
keithbrinks opened this issue Nov 11, 2020 · 23 comments
Closed

MacOS Big Sur #1213

keithbrinks opened this issue Nov 11, 2020 · 23 comments

Comments

@keithbrinks
Copy link

With MacOS Big Sur set to be released tomorrow, I setup a fresh installation (11.0.1) of the public beta in a VM to test my application + dependencies.

I installed PHP via Homebrew (brew install php) and have 7.4.12 installed.

I then installed the ODBC driver via:

brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
brew update
HOMEBREW_NO_ENV_FILTERING=1 ACCEPT_EULA=Y brew install msodbcsql17 mssql-tools

The ODBC driver appears to have installed successfully.

Finally, I attempted to install the PDO_SQSRV driver via pecl:

pecl install pdo_sqlsrv

This is resulting in the following messages:

ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [pdo_sqlsrv.la] Error 1
ERROR: `make' failed

I have used the steps above to successfully install PDO_SQLSRV on macOS Catalina, using PHP 7.4.8, which was the latest release at the time.

Thanks

@yitam
Copy link
Contributor

yitam commented Nov 12, 2020

Thanks @keithbrinks we will do the investigation on our side and get back to you on this.

@yitam yitam added the macOS label Nov 12, 2020
@abdulwahhabkhan
Copy link

Same error I am getting.

ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [sqlsrv.la] Error 1
ERROR: `make' failed

MAC OS:
image

Brew:
Homebrew 2.5.11 Homebrew/homebrew-core (git revision f4b6f; last commit 2020-11-16)

Pecl:
PEAR Version: 1.10.12 PHP Version: 7.4.12 Zend Engine Version: 3.4.0

@yitam
Copy link
Contributor

yitam commented Nov 16, 2020

Yes @abdulwahhabkhan we are aware of this issue. We do not officially support macOS Big Sur yet, but we are looking into this. Please stay tuned.

@keithbrinks
Copy link
Author

Thanks @yitam

I did end up upgrading over the weekend. The driver does work if it was already compiled/installed. Just can't install fresh.

@yitam
Copy link
Contributor

yitam commented Nov 16, 2020

Thanks for the info @keithbrinks. I'm sure some people will find it useful.

Homebrew does not provide support for macOS Big Sur yet but is working on it

@abdulwahhabkhan
Copy link

Hi @yitam ,

Thanks for the update, do we have any other way to install the SQLSRV meanwhile its get fixed?

I just moved from windows to MAC and due to this struggling a lot :(

Thanks

@yitam
Copy link
Contributor

yitam commented Nov 19, 2020

@abdulwahhabkhan please use other macOS that we officially support, from High Sierra to Catalina.

@nm777
Copy link

nm777 commented Nov 19, 2020

For those who are looking to get the MSSQL driver working on Big Sur, you can manually download the binaries and install them. Here is how I did that:

  1. Download the binaries: https://github.com/Microsoft/msphpsql/releases. I'm running PHP 7.4, so I downloaded the file Mac-7.4.tar under v5.8.1.
  2. Locate the directory your PHP extensions are stored in:
$ php --info | grep extension_dir
extension_dir => /usr/local/lib/php/pecl/20190902 => /usr/local/lib/php/pecl/20190902
sqlite3.extension_dir => no value => no value

In my case, for some reason the extension_dir that PHP reports isn't where other extensions are located: /usr/local/lib/php/20190902 -- note the missing pecl folder. You can put them anywhere you want. If you choose not to use the reported extension_dir you'll simply need to specify the full path to the drivers.
3. Extract the tar file you downloaded in step 1 and copy the .so files to the extension directory you determined in step 2. There are both threadsafe and non-threadsafe drivers. For a discussion about those, go here. You probably don't need both, but do whatever you like.
4. Identify where PHP reads its configuration from:

$ php --ini
Configuration File (php.ini) Path: /usr/local/etc/php/7.4
Loaded Configuration File:         /usr/local/etc/php/7.4/php.ini
Scan for additional .ini files in: /usr/local/etc/php/7.4/conf.d  <=== We want this one
Additional .ini files parsed:      /usr/local/etc/php/7.4/conf.d/ext-opcache.ini
  1. Create a file named ext-sqlsrv.conf and place it in the directory listed above. Use PHP's rules (documented in the base php.ini file) for details on how to set yours. Here are a couple of examples:
# Example: Using a full path
$ echo -e "extension=/usr/local/lib/php/20190902/php_sqlsrv_74_nts.so\nextension=/usr/local/lib/php/20190902/php_pdo_sqlsrv_74_nts.so" >/usr/local/etc/php/7.4/conf.d/ext-sqlsrv.ini

# ----- OR -----

# Example: File is located in `extension_dir` and matches PHP's expected naming convention
$ mv /usr/local/lib/php/20190902/php_sqlsrv_74_nts.so /usr/local/lib/php/20190902/php_sqlsrv.so
$ mv /usr/local/lib/php/20190902/php_pdo_sqlsrv_74_nts.so /usr/local/lib/php/20190902/php_pdo_sqlsrv.so
$ echo -e "extension=sqlsrv\nextension=pdo_sqlsrv" >/usr/local/etc/php/7.4/conf.d/ext-sqlsrv.ini
  1. Check to verify that the sqlsrv and pdo_sqlsrv drivers are loaded:
$ php --info | grep 'sqlsrv support'
pdo_sqlsrv support => enabled
sqlsrv support => enabled

@yitam
Copy link
Contributor

yitam commented Nov 19, 2020

Thanks @nm777 for your info!

Yet, sqlsrv / pdo_sqlsrv depends on the ODBC driver, which does not officially support Big Sur either for the time being.

@nm777
Copy link

nm777 commented Nov 19, 2020

@yitam, that's a good point. However, for me I can say that the steps in the Microsoft docs (https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/install-microsoft-odbc-driver-sql-server-macos?view=sql-server-ver15) for installing the ODBC drivers worked and in combination with the steps above, I'm able to query my local (docker-based) MSSQL instance from my PHP application.

Obviously in an unsupported configuration like this, others may have different results. I'm hoping my experience helps someone along the way.

@yitam
Copy link
Contributor

yitam commented Nov 19, 2020

Thanks @nm777 again for your contributions! This is in our priority list and we will get to it as soon as possible.

@abdulwahhabkhan
Copy link

Thanks @nm777 ,

I followed the esxample you given but get following errors:

/usr/local/lib/php/pecl/20190902/sqlsrv.so: code signature in (/usr/local/lib/php/pecl/20190902/sqlsrv.so) not valid for use in process using Library Validation: library load disallowed by system policy)) in Unknown

Any idea how to solve this.

Thanks

@nm777
Copy link

nm777 commented Nov 21, 2020

I forgot that the first time I used the drivers I believe Mac's security kicked in. If you go to System Preferences >> Security & Privacy >> General, do you see a warning in the lower section about a blocked app? If so, click the button to allow it. You'll have to do this twice since there are 2 drivers.

I hope I'm not forgetting anything else....

@abdulwahhabkhan
Copy link

Thanks @nm777

It workks

Thanks

@yitam
Copy link
Contributor

yitam commented Dec 2, 2020

Just released 5.9.0-beta2. This will be the last preview before the stable release. Even though we do not yet officially support Big Sur, pecl install should work as shown below.

sudo pecl install sqlsrv-5.9.0beta2
sudo pecl install pdo_sqlsrv-5.9.0beta2

@yitam
Copy link
Contributor

yitam commented Dec 9, 2020

Closing this issue due to inactivity. Please feel free to reopen this if necessary.

@yitam yitam closed this as completed Dec 9, 2020
@justindantzer
Copy link

Found this issue looking for Big Sur help, and the beta install noted previously was almost successful, but I ran into this at the end:

Build process completed successfully
Installing '/usr/local/Cellar/php/8.0.1_1/pecl/20200930/pdo_sqlsrv.so'

Warning: mkdir(): File exists in System.php on line 294

Warning: mkdir(): File exists in /usr/local/Cellar/php/8.0.1_1/share/php/pear/System.php on line 294
ERROR: failed to mkdir /usr/local/Cellar/php/8.0.1_1/pecl/20200930

PHP

PHP 8.0.1 (cli) (built: Jan  8 2021 12:43:54) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.1, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.1, Copyright (c), by Zend Technologies

PECL

PEAR Version: 1.10.12
PHP Version: 8.0.1
Zend Engine Version: 4.0.1
Running on: Darwin Macintarnation 20.2.0 Darwin Kernel Version 20.2.0: Wed Dec  2 20:39:59 PST 2020; root:xnu-7195.60.75~1/RELEASE_X86_64 x86_64

HOMEBREW

Homebrew 2.7.5
Homebrew/homebrew-core (git revision 3e9702; last commit 2021-01-15)
Homebrew/homebrew-cask (git revision bca5e; last commit 2021-01-15)

Any help would be greatly appreciated

@yitam
Copy link
Contributor

yitam commented Jan 15, 2021

Hi @justindantzer , this is a known issue with macOS install. Please check our FAQ Why pecl install fails on macOS with "Warning: mkdir(): File exists in System.php" message?

@armadeas
Copy link

armadeas commented Jan 24, 2021

sudo pecl install sqlsrv-5.9.0beta2

I can install this library, but when running an error like this appears in Bigsur PHP 7.4.11

Exception Message:\n\nSQLSTATE[IMSSP]: This extension requires the Microsoft ODBC Driver for SQL Server to communicate with SQL Server. Access the following URL to download the ODBC Driver for SQL Server for x64: https:\/\/go.microsoft.com\/fwlink\/?LinkId=163712

Solved install
https://docs.microsoft.com/id-id/sql/connect/odbc/linux-mac/install-microsoft-odbc-driver-sql-server-macos?view=sql-server-ver15

@yitam
Copy link
Contributor

yitam commented Jan 25, 2021

Yes @armadeas. In case other people are looking for an answer to this, the ODBC driver is the prerequisite to sqlsrv or pdo_sqlsrv

@genialcode2077

This comment has been minimized.

@yitam
Copy link
Contributor

yitam commented Sep 13, 2021

Hi @angelsv please try again by following the instructions here
https://github.com/microsoft/msphpsql/blob/master/Linux-mac-install.md#installing-the-drivers-on-macos

@genialcode2077
Copy link

@yitam Perfect!!! thanks

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

No branches or pull requests

7 participants