Problema de instalação do driver SQLSRV no sistema Ubuntu 16.04 de 32 bits

0

Estou tentando instalar o driver sqlsrv em meu sistema Ubuntu 16.04 os, mas recebo este erro

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

Como posso resolver este problema? Por favor, note isso, minha versão do PHP é 7.0.22 e os é ubuntu0.16.04.1 (cli) (NTS).

    
por shijin 11.08.2017 / 20:13

2 respostas

5

Você deve seguir as instruções oficiais de instalação da Microsoft.

Consulte: Instalando o Microsoft ODBC Driver para SQL Server no Linux e no MacOS (também PDF manual ).

Os seguintes passos são copiados do guia:

Etapa 1. Instalar o 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 

Etapa 2. Instalar Pré-requisitos

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 

Etapa 3. Instalar os drivers PHP para o 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
    
por Andrea Lazzarotto 13.08.2017 / 21:39
1

A resposta acima funciona se você adicionar o seguinte:

altere 7.x no seguinte para a sua versão atual ls / etc / php / para encontrá-lo

echo "extension = sqlsrv.so" > > /etc/php/7.x/apache2/php.ini echo "extension = pdo_sqlsrv.so" > > /etc/php/7.x/apache2/php.ini

    
por Charles Jordan 20.04.2018 / 13:46