SQLSRV driver installation problem in Ubuntu 16.04 32-bit system

I'm trying to install sqlsrv driver in my Ubuntu 16.04 os system, but I get this error

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

How can I solve this problem? Please note this, my PHP version is 7.0.22 and os is ubuntu0.16.04.1 (cli) ( NTS ).

4

2 Answers

You should follow the official installation instructions from Microsoft.

See: Installing the Microsoft ODBC Driver for SQL Server on Linux and macOS (also PDF manual).

The following steps are copied from the guide:

Step 1. Install 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 

Step 2. Install prerequisites

sudo su
curl | apt-key add -
curl > /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 

Step 3. Install the PHP drivers for 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
14

The answer above works if you add the following:

change 7.x in the following to your current version ls /etc/php/ to find it

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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like