msphpsql: Mac install "fatal error: 'sql.h' file not found"
Trying to following install steps for Mac here under Step 2: https://www.microsoft.com/en-us/sql-server/developer-get-started/php-mac
- Driver Version: sqlsrv-4.1.7preview pdo_sqlsrv-4.1.7preview
- OS Version and Distro: macOS Sierra 10.12
- Can you connect to SQL Server via sqlcmd: NO
- Environment details: PHP 7.1.0 installed via Laravel Valet (https://laravel.com/docs/5.4/valet)
Steps to Reproduce:
brew tap microsoft/mssql-preview https://github.com/Microsoft/homebrew-mssql-preview
brew update
brew install unixodbc
brew install msodbcsql
brew install mssql-tools
brew install llvm --with-clang --with-clang-extra-tools
brew install autoconf
sudo pecl install sqlsrv-4.1.7preview pdo_sqlsrv-4.1.7preview
sudo echo "extension= pdo_sqlsrv.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
sudo echo "extension= sqlsrv.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
Receive the following error running sudo pecl install sqlsrv-4.1.7preview pdo_sqlsrv-4.1.7preview command: fatal error: 'sql.h' file not found
Full log from that step: http://ander.ly/A9Zr+
The sql.h file is indeed there: http://ander.ly/kMVV
Tried uninstalling all packages and installing again and unlinking unixodbc and relinking to no avail. Further info in this comment thread: https://www.microsoft.com/en-us/sql-server/developer-get-started/php-mac#comment-3272933953
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 27 (13 by maintainers)
So, redoing
brew install homebrew/php/php71fixed it. I’m wondering if the issue was that I had installed Laravel Valet prior to upgrading to macOS Sierra and then updating to Sierra may have put PHP 5.6 back in /usr/local/bin. So, while valet and laravel were working and command line were showing php version 7.1, I think pear/pecl were still trying to use 5.6.Also, I installed the 4.1.8 version.
Thanks again for all the help troubleshooting!
Ok, so after adding
/usr/local/binto beginning of path,php -vreturns5.6so it’s finding the default php included with MacOS. I’m retryingbrew install php71 --with-pearto see if that corrects, but I may have to fully remove the 5.6 version since it may be conflicting.Hi @anderly, I’m looking into this. In the meantime, could you please check a few things?
php -vfind / -name sql.hYou should see something like these:
/usr/local/Cellar/unixodbc/2.3.4/include/sql.h/usr/local/include/sql.hNext, what’s the path
echo $PATHThanks!