'Get sql.h error on MacOS 12 (Monterey) sqsrv and pdo_sqsrv drive installation
I have macOS 12 Monterey, PHP 7.4. I would like to install sqlsrv and pdo_sqlsrv drives. However, I got the following error.
g++ -I/opt/homebrew/Cellar/[email protected]/7.4.27/include/php/ext -std=c++11 -I. -I/private/tmp/pear/temp/pdo_sqlsrv -DPHP_ATOM_INC -I/private/tmp/pear/temp/pear-build-rootbnJKua/pdo_sqlsrv-5.9.0/include -I/private/tmp/pear/temp/pear-build-rootbnJKua/pdo_sqlsrv-5.9.0/main -I/private/tmp/pear/temp/pdo_sqlsrv -I/opt/homebrew/Cellar/[email protected]/7.4.27/include/php -I/opt/homebrew/Cellar/[email protected]/7.4.27/include/php/main -I/opt/homebrew/Cellar/[email protected]/7.4.27/include/php/TSRM -I/opt/homebrew/Cellar/[email protected]/7.4.27/include/php/Zend -I/opt/homebrew/Cellar/[email protected]/7.4.27/include/php/ext -I/opt/homebrew/Cellar/[email protected]/7.4.27/include/php/ext/date/lib -I/private/tmp/pear/temp/pdo_sqlsrv/shared/ -DHAVE_CONFIG_H -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector -c /private/tmp/pear/temp/pdo_sqlsrv/pdo_dbh.cpp -fno-common -DPIC -o .libs/pdo_dbh.o
In file included from /private/tmp/pear/temp/pdo_sqlsrv/pdo_dbh.cpp:24:
In file included from /private/tmp/pear/temp/pdo_sqlsrv/php_pdo_sqlsrv_int.h:23:
In file included from /private/tmp/pear/temp/pdo_sqlsrv/shared/core_sqlsrv.h:41:
In file included from /private/tmp/pear/temp/pdo_sqlsrv/shared/FormattedPrint.h:24:
In file included from /private/tmp/pear/temp/pdo_sqlsrv/shared/xplat_winnls.h:24:
In file included from /private/tmp/pear/temp/pdo_sqlsrv/shared/typedefs_for_linux.h:23:
/private/tmp/pear/temp/pdo_sqlsrv/shared/xplat.h:30:10: fatal error: 'sql.h' file not found
#include <sql.h>
^~~~~~~
1 error generated.
make: *** [pdo_dbh.lo] Error 1
ERROR: `make' failed
I also try 5.10.0-beta2 (pre-release) [1]: https://github.com/microsoft/msphpsql/releases/. But I still get the same error. Did I miss any steps or the release is not ready for macOS 12. Thanks
Solution 1:[1]
This may be helpful, even though I came across the issue while installing ODBC packages in Python in Monterey on an M1 Mac, as opposed to PHP.
Assuming that you have installed unixodbc
via brew (brew install unixodbc
), your compiler header files will be somewhere like:
/opt/homebrew/Cellar/unixodbc/2.3.9_1/include
All, you need to do is adding this path to your CPPFLAGs during compiling. In my case in particular:
CPPFLAGS='-I/opt/homebrew/Cellar/unixodbc/2.3.9_1/include' pip install pyodbc
Solution 2:[2]
In my case, MacOS Monterey 12.1 works with:
sudo CPPFLAGS='-I/opt/homebrew/Cellar/unixodbc/2.3.11/include' LDFLAGS='-L/opt/homebrew/Cellar/unixodbc/2.3.11/lib' pecl install pdo_sqlsrv sqlsrv
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Sojoodi |
Solution 2 | jona303 |