Проблема установки драйвера SQLSRV в 32-битной системе Ubuntu 16.04
Я пытаюсь установить драйвер sqlsrv в систему Ubuntu 16.04 os, но я получаю эту ошибку
running: make
/bin/bash /tmp/pear/temp/pear-build-rootliPAYQ/sqlsrv-4.3.0/libtool
--mode=compile g++ -std=c++11 -I. -I/tmp/pear/temp/sqlsrv -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootliPAYQ/sqlsrv-4.3.0/include
-I/tmp/pear/temp/pear-build-rootliPAYQ/sqlsrv-4.3.0/main
-I/tmp/pear/temp/sqlsrv -I/usr/include/php/20151012 -I/usr/include
/php/20151012/main -I/usr/include/php/20151012/TSRM -I/usr/include
/php/20151012/Zend -I/usr/include/php/20151012/ext -I/usr/include
/php/20151012/ext/date/lib -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
-I/tmp/pear/temp/sqlsrv/shared/ -DHAVE_CONFIG_H -std=c++11
-D_FORTIFY_SOURCE=2 -O2 -fstack-protector -c /tmp/pear/temp/sqlsrv
/conn.cpp -o conn.lo
libtool: compile: g++ -std=c++11 -I. -I/tmp/pear/temp/sqlsrv -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootliPAYQ/sqlsrv-4.3.0/include -I/tmp/pear/temp/pear-build-rootliPAYQ/sqlsrv-4.3.0/main
-I/tmp/pear/temp/sqlsrv -I/usr/include/php/20151012 -I/usr/include/php/20151012/
main -I/usr/include/php/20151012/TSRM -I/usr/include/php/20151012/Zend
-I/usr/include/php/20151012/ext -I/usr/include/php/20151012/ext/date/
lib -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
-I/tmp/pear/temp/sqlsrv/shared/
-DHAVE_CONFIG_H -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector -c /tmp/pear/
temp/sqlsrv/conn.cpp -fPIC -DPIC -o .libs/conn.o In file included from /tmp/pear/
temp/sqlsrv/shared/xplat.h:99:0,
from /tmp/pear/temp/sqlsrv/shared/typedefs_for_linux.h:23,
from /tmp/pear/temp/sqlsrv/shared/xplat_winnls.h:24,
from /tmp/pear/temp/sqlsrv/shared/FormattedPrint.h:24,
from /tmp/pear/temp/sqlsrv/shared/core_sqlsrv.h:41,
from /tmp/pear/temp/sqlsrv/php_sqlsrv.h:25,
from /tmp/pear/temp/sqlsrv/conn.cpp:20:
/tmp/pear/temp/sqlsrv/shared/xplat_intsafe.h:50:29: error: conflicting declaration
‘typedef windowsULong_t DWORD’
typedef windowsULong_t DWORD;
^
In file included from /usr/include/sql.h:19:0,
from /tmp/pear/temp/sqlsrv/shared/xplat.h:30,
from /tmp/pear/temp/sqlsrv/shared/typedefs_for_linux.h:23,
from /tmp/pear/temp/sqlsrv/shared/xplat_winnls.h:24,
from /tmp/pear/temp/sqlsrv/shared/FormattedPrint.h:24,
from /tmp/pear/temp/sqlsrv/shared/core_sqlsrv.h:41,
from /tmp/pear/temp/sqlsrv/php_sqlsrv.h:25,
from /tmp/pear/temp/sqlsrv/conn.cpp:20:
/usr/include/sqltypes.h:96:24: note: previous declaration as ‘typedef long unsigned int DWORD’
typedef unsigned long DWORD;
^
Makefile:194: recipe for target 'conn.lo' failed
make: *** [conn.lo] Error 1
ERROR: `make' failed
Как я могу решить эту проблему? Обратите внимание: моя версия PHP - 7.0.22, а os - ubuntu0.16.04.1 (cli) ( NTS).
2 ответа
Вы должны следовать официальным инструкциям по установке от Microsoft.
См.: Установка драйвера Microsoft ODBC для SQL Server в Linux и macOS (также руководство в формате PDF).
Следующие шаги скопированы из руководства:
Шаг 1. Установите PHP
sudo su
apt-get update
apt-get -y install php7.0 mcrypt php7.0-mcrypt php-mbstring php-pear php7.0-dev
php7.0-xml
Шаг 2. Установите необходимые условия
sudo su
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
exit
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql mssql-tools
sudo apt-get install unixodbc-dev
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
Шаг 3. Установите драйверы PHP для Microsoft SQL Server
sudo pear config-set php_ini `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` system
sudo pecl install sqlsrv
sudo pecl install pdo_sqlsrv
Ответ выше работает, если вы добавите следующее:
замените 7.x в следующей версии на вашу текущую версию ls / etc / php /, чтобы найти ее
echo "extension=sqlsrv.so" >> /etc/php/7.x/apache2/php.ini echo "extension=pdo_sqlsrv.so" >> /etc/php/7.x/apache2/php.ini