microsoft / msphpsql

Microsoft Drivers for PHP for SQL Server
MIT License
1.8k stars 373 forks source link

Cannot get sqlsrv installed on SLES #451

Closed hbunjes closed 6 years ago

hbunjes commented 7 years ago

Hi, I try to install sqlsrv and pdo_sqlsrv on a Suse Linux Enterprise server to access SQL Server with PHP.

After installing all required packages I run:

sudo pecl install sqlsrv

This is the output: downloading sqlsrv-4.0.8.tar ... Starting to download sqlsrv-4.0.8.tar (1,034,240 bytes) ..............done: 1,034,240 bytes 33 source files, building running: phpize Configuring for: PHP Api Version: 20151012 Zend Module Api No: 20151012 Zend Extension Api No: 320151012 building in /tmp/pear/temp/pear-build-root8kM4T6/sqlsrv-4.0.8 running: /tmp/pear/temp/sqlsrv/configure --with-php-config=/usr/bin/php-config checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for a sed that does not truncate output... /usr/bin/sed checking for cc... cc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether cc accepts -g... yes checking for cc option to accept ISO C89... none needed checking how to run the C preprocessor... cc -E checking for icc... no checking for suncc... no checking whether cc understands -c and -o together... yes checking for system library directory... lib checking if compiler supports -R... no checking if compiler supports -Wl,-rpath,... yes checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu checking for PHP prefix... /usr checking for PHP includes... -I/usr/include/php7 -I/usr/include/php7/main -I/usr/include/php7/TSRM -I/usr/include/php7/Zend -I/usr/include/php7/ext -I/usr/include/php7/ext/date/lib checking for PHP extension directory... /usr/lib64/php7/extensions checking for PHP installed headers prefix... /usr/include/php7 checking if debug is enabled... no checking if zts is enabled... no checking for re2c... no configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers. checking for gawk... gawk checking whether to enable sqlsrv functions... yes, shared checking for SQLSRV headers... /tmp/pear/temp/sqlsrv/shared/ checking for g++... no checking for c++... no checking for gpp... no checking for aCC... no checking for CC... no checking for cxx... no checking for cc++... no checking for cl.exe... no checking for FCC... no checking for KCC... no checking for RCC... no checking for xlC_r... no checking for xlC... no checking whether we are using the GNU C++ compiler... no checking whether g++ accepts -g... no checking how to run the C++ preprocessor... /lib/cpp checking how to print strings... printf checking for a sed that does not truncate output... (cached) /usr/bin/sed checking for fgrep... /usr/bin/grep -F checking for ld used by cc... /usr/x86_64-suse-linux/bin/ld checking if the linker (/usr/x86_64-suse-linux/bin/ld) is GNU ld... yes checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B checking the name lister (/usr/bin/nm -B) interface... BSD nm checking whether ln -s works... yes checking the maximum length of command line arguments... 1572864 checking whether the shell understands some XSI constructs... yes checking whether the shell understands "+="... yes checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop checking for /usr/x86_64-suse-linux/bin/ld option to reload object files... -r checking for objdump... objdump checking how to recognize dependent libraries... pass_all checking for dlltool... no checking how to associate runtime and link libraries... printf %s\n checking for ar... ar checking for archiver @FILE support... @ checking for strip... strip checking for ranlib... ranlib checking for gawk... (cached) gawk checking command to parse /usr/bin/nm -B output from cc object... ok checking for sysroot... no checking for mt... mt checking if mt is a manifest tool... no checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking for dlfcn.h... yes checking for objdir... .libs checking if cc supports -fno-rtti -fno-exceptions... no checking for cc option to produce PIC... -fPIC -DPIC checking if cc PIC flag -fPIC -DPIC works... yes checking if cc static flag -static works... no checking if cc supports -c -o file.o... yes checking if cc supports -c -o file.o... (cached) yes checking whether the cc linker (/usr/x86_64-suse-linux/bin/ld -m elf_x86_64) supports shared libraries... yes checking whether -lc should be explicitly linked in... no checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... no configure: creating ./config.status config.status: creating config.h config.status: executing libtool commands running: make /bin/sh /tmp/pear/temp/pear-build-root8kM4T6/sqlsrv-4.0.8/libtool --mode=compile g++ -std=c++11 -I. -I/tmp/pear/temp/sqlsrv -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-root8kM4T6/sqlsrv-4.0.8/include -I/tmp/pear/temp/pear-build-root8kM4T6/sqlsrv-4.0.8/main -I/tmp/pear/temp/sqlsrv -I/usr/include/php7 -I/usr/include/php7/main -I/usr/include/php7/TSRM -I/usr/include/php7/Zend -I/usr/include/php7/ext -I/usr/include/php7/ext/date/lib -I/tmp/pear/temp/sqlsrv/shared/ -DHAVE_CONFIG_H -std=c++11 -c /tmp/pear/temp/sqlsrv/conn.cpp -o conn.lo libtool: compile: unable to infer tagged configuration libtool: compile: specify a tag with --tag' Makefile:194: recipe for target 'conn.lo' failed make: *** [conn.lo] Error 1 ERROR:make' failed

The error occurs no matter which sqlsrv version I try to install (I tried 4.0.8 and all following preview and RC1).

Thank you, Hilmar

lilgreenbird commented 7 years ago

Hi @hbunjes

Suse is not a supported platform, however you could try to compile and install this yourself. I could give you some general guidance to help get you started but we can not provide any support for that as we have not done any testing on that platform. We currently only build and test binaries for Ubuntu 15, Ubuntu 16, RHEL7, Debian8 so these are the only platforms that we support. Please note that none of the instructions below has been tested on other Linux distributions.

To use PHP you would need to install the ODBC Driver for SQL Server as that is a dependency for PHP. ODBC supports Suse you can reference the official ODBC install instructions here . That should install the ODBC and UnixODBC packages for you. Please make sure that's all working the setup is correct and you are able to connect with the ODBC driver before attempting to install the PHP driver.

Then you can try to install our PHP driver package using PECL: sudo pecl install sqlsrv-4.2.0preview for the latest version.

wget https://github.com/Microsoft/msphpsql/archive/dev.tar.gz
tar -xf dev.tar.gz
cd msphpsql-dev/source/sqlsrv
cp -r ../shared/ .
phpize
./configure
make

Alternatively you could also try to compile our driver with the PHP source:

wget https://github.com/Microsoft/msphpsql/archive/dev.tar.gz
tar -xf dev.tar.gz
wget http://ca1.php.net/get/php-7.0.20.tar.gz/from/this/mirror -O php-7.0.20.tar.gz
tar -xf php-7.0.20.tar.gz
cp -r msphpsql-dev/source/sqlsrv/ php-7.0.20/ext/
cp -r msphpsql-dev/source/shared/ php-7.0.20/ext/sqlsrv/
cd php-7.0.20/
./buildconf --force
./configure --enable-sqlsrv=shared  --with-odbcver=0x0380
make

Hopefully that can get you started. Good luck!

hbunjes commented 7 years ago

Thank you @lilgreenbird

I could get the files compiled when I add the "--tag=CXX" option before g++: .../libtool --mode=compile --tag=CXX g++ -std=c++11 ...

For any reason I don't know libtool wasn't able top recognize that I want to compile C++ files...

However, linking did not work at the next stage: /bin/sh /root/sqlsrv_php/msphpsql-dev/source/sqlsrv/libtool --mode=link cc -DPHP_ATOM_INC -I/root/sqlsrv_php/msphpsql-dev/source/sqlsrv/include -I/root/sqlsrv_php/msphpsql-dev/source/sqlsrv/main -I/root/sqlsrv_php/msphpsql-dev/source/sqlsrv -I/usr/include/php7 -I/usr/include/php7/main -I/usr/include/php7/TSRM -I/usr/include/php7/Zend -I/usr/include/php7/ext -I/usr/include/php7/ext/date/lib -I/root/sqlsrv_php/msphpsql-dev/source/sqlsrv/shared -DHAVE_CONFIG_H -g -O2 -o sqlsrv.la -export-dynamic -avoid-version -prefer-pic -module -rpath /root/sqlsrv_php/msphpsql-dev/source/sqlsrv/modules conn.lo util.lo init.lo stmt.lo shared/core_conn.lo shared/core_results.lo shared/core_stream.lo shared/core_init.lo shared/core_stmt.lo shared/core_util.lo shared/FormattedPrint.lo shared/localizationimpl.lo shared/StringFunctions.lo -lstdc++ -lodbc -lodbcinst libtool: link: cc -shared -fPIC -DPIC .libs/conn.o .libs/util.o .libs/init.o .libs/stmt.o shared/.libs/core_conn.o shared/.libs/core_results.o shared/.libs/core_stream.o shared/.libs/core_init.o shared/.libs/core_stmt.o shared/.libs/core_util.o shared/.libs/FormattedPrint.o shared/.libs/localizationimpl.o shared/.libs/StringFunctions.o -Wl,-rpath -Wl,/usr/lib64 -Wl,-rpath -Wl,/usr/lib64 -lstdc++ /usr/lib64/libodbc.so -L/usr/lib64 /usr/lib64/libodbcinst.so /usr/lib64/libltdl.so -ldl -lpthread -O2 -pthread -Wl,-soname -Wl,sqlsrv.so -o .libs/sqlsrv.so /usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: .libs/conn.o: relocation R_X86_64_32 against `_ZN2ss11SSExceptionD1Ev' can not be used when making a shared object; recompile with -fPIC .libs/conn.o: error adding symbols: Bad value collect2: error: ld returned 1 exit status Makefile:223: recipe for target 'sqlsrv.la' failed make: *** [sqlsrv.la] Error 1

I'm going to stop try using SQL Server in this project and will fall back to sqlite or the MariaDB cluster.

Thank you for your help! Maybe you could see this as a feature request as there are (at least in Germany and parts of the USA) quite a lot of SLES installations in companies also using SQL Server.

Best, Hilmar

lilgreenbird commented 7 years ago

hi @hbunjes, I'm sorry I'm not able to provide you with much assistance on this as we haven't tried this here since it's currently not 1 of our supported platforms. ODBC driver does support SLES however and so I'm sure this is 1 of the things being considered in our product roadmap. For now I have added a feature request label to this issue. Thank you.

meet-bhagdev commented 7 years ago

@hbunjes Apologies that you are having trouble with SLES. Have you installed the unixODBC-devel package? We can definitely add support for SLES officially. What timeline are you aiming for?

meet-bhagdev commented 7 years ago

@hbunjes One more question, what version of SLES are you using?

Hadis-Knj commented 7 years ago

@hbunjes I could reproduce the issue, the problem is coming from libltdl library, if you install libtool you can get the sqlsrv compiled.

1- Install ODBC and unixODBC, make sure you have installed unixODBC-devel, it installs the required header files for sqlsrv drivers

sudo su
zypper ar https://packages.microsoft.com/config/sles/12/prod.repo
exit
sudo ACCEPT_EULA=Y zypper install msodbcsql
# optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y zypper install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
sudo zypper install unixODBC-devel

2- Install required lib and dependencies. zypper in libtool zypper in autoconf zypper in libxml2-2 or libxml2 zypper in gcc zypper in gcc-c++

3- Install PHP 7, you can either install it from package or download the php source and install it as below:

cd ~/Downloads/
tar -xzvf ./php-7.1.6.tar.gz
cd php-7.1.6/
./buildconf --force
./configure 
make
sudo make install

4- Intall sqlsrv drivers

meet-bhagdev commented 7 years ago

We will also add official support for SLES in the next 1-2 preview releases

yitam commented 6 years ago

Closing this as we have added support for SUSE 12 as of 5.1.0-preview. You might want to test 5.2.0-RC however. Please feel free to re-open this should you have any problem, @hbunjes. Thanks!

dhirajranka commented 3 years ago

downloading sqlsrv-5.8.1.tgz ... Starting to download sqlsrv-5.8.1.tgz (186,879 bytes) ........................................done: 186,879 bytes downloading pdo_sqlsrv-5.8.1.tgz ... Starting to download pdo_sqlsrv-5.8.1.tgz (181,286 bytes) ...done: 181,286 bytes 34 source files, building running: phpize grep: /usr/include/php/main/php.h: No such file or directory grep: /usr/include/php/Zend/zend_modules.h: No such file or directory grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory Configuring for: PHP Api Version: Zend Module Api No: Zend Extension Api No: building in /private/var/tmp/pear/temp/pear-build-rooteMj21b/sqlsrv-5.8.1 running: /private/var/tmp/pear/temp/sqlsrv/configure --with-php-config=/usr/bin/php-config checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for a sed that does not truncate output... /usr/bin/sed checking for cc... cc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether cc accepts -g... yes checking for cc option to accept ISO C89... none needed checking how to run the C preprocessor... cc -E checking for icc... no checking for suncc... no checking whether cc understands -c and -o together... yes checking for system library directory... lib checking if compiler supports -R... no checking if compiler supports -Wl,-rpath,... yes checking build system type... x86_64-apple-darwin19.6.0 checking host system type... x86_64-apple-darwin19.6.0 checking target system type... x86_64-apple-darwin19.6.0 checking for PHP prefix... /usr checking for PHP includes... -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib checking for PHP extension directory... /usr/lib/php/extensions/no-debug-non-zts-20180731 checking for PHP installed headers prefix... /usr/include/php checking if debug is enabled... no checking if zts is enabled... no checking for re2c... no configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers. checking for gawk... no checking for nawk... no checking for awk... awk checking if awk is broken... no checking whether to enable sqlsrv functions... yes, shared checking for SQLSRV headers... /private/var/tmp/pear/temp/sqlsrv/shared/ checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking how to run the C++ preprocessor... g++ -E checking for ld used by cc... /Library/Developer/CommandLineTools/usr/bin/ld checking if the linker (/Library/Developer/CommandLineTools/usr/bin/ld) is GNU ld... no checking for /Library/Developer/CommandLineTools/usr/bin/ld option to reload object files... -r checking for BSD-compatible nm... /usr/bin/nm -B checking whether ln -s works... yes checking how to recognize dependent libraries... pass_all checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking dlfcn.h usability... yes checking dlfcn.h presence... yes checking for dlfcn.h... yes checking how to run the C++ preprocessor... g++ -E checking the maximum length of command line arguments... 196608 checking command to parse /usr/bin/nm -B output from cc object... ok checking for objdir... .libs checking for ar... ar checking for ranlib... ranlib checking for strip... strip checking for dsymutil... dsymutil checking for nmedit... nmedit checking for -single_module linker flag... yes checking for -exported_symbols_list linker flag... yes checking if cc supports -fno-rtti -fno-exceptions... yes checking for cc option to produce PIC... -fno-common checking if cc PIC flag -fno-common works... yes checking if cc static flag -static works... no checking if cc supports -c -o file.o... yes checking whether the cc linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes checking dynamic linker characteristics... darwin19.6.0 dyld checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... no

creating libtool appending configuration tag "CXX" to libtool checking for ld used by g++... /Library/Developer/CommandLineTools/usr/bin/ld checking if the linker (/Library/Developer/CommandLineTools/usr/bin/ld) is GNU ld... no checking whether the g++ linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes checking for g++ option to produce PIC... -fno-common checking if g++ PIC flag -fno-common works... yes checking if g++ static flag -static works... no checking if g++ supports -c -o file.o... yes checking whether the g++ linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes checking dynamic linker characteristics... darwin19.6.0 dyld (cached) (cached) checking how to hardcode library paths into programs... immediate configure: creating ./config.status config.status: creating config.h running: make /bin/sh /private/var/tmp/pear/temp/pear-build-rooteMj21b/sqlsrv-5.8.1/libtool --mode=compile g++ -std=c++11 -I. -I/private/var/tmp/pear/temp/sqlsrv -DPHP_ATOM_INC -I/private/var/tmp/pear/temp/pear-build-rooteMj21b/sqlsrv-5.8.1/include -I/private/var/tmp/pear/temp/pear-build-rooteMj21b/sqlsrv-5.8.1/main -I/private/var/tmp/pear/temp/sqlsrv -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/private/var/tmp/pear/temp/sqlsrv/shared/ -DHAVE_CONFIG_H -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector -c /private/var/tmp/pear/temp/sqlsrv/conn.cpp -o conn.lo mkdir .libs g++ -std=c++11 -I. -I/private/var/tmp/pear/temp/sqlsrv -DPHP_ATOM_INC -I/private/var/tmp/pear/temp/pear-build-rooteMj21b/sqlsrv-5.8.1/include -I/private/var/tmp/pear/temp/pear-build-rooteMj21b/sqlsrv-5.8.1/main -I/private/var/tmp/pear/temp/sqlsrv -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/private/var/tmp/pear/temp/sqlsrv/shared/ -DHAVE_CONFIG_H -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector -c /private/var/tmp/pear/temp/sqlsrv/conn.cpp -fno-common -DPIC -o .libs/conn.o In file included from /private/var/tmp/pear/temp/sqlsrv/conn.cpp:21: /private/var/tmp/pear/temp/sqlsrv/php_sqlsrv.h:25:10: fatal error: 'php.h' file not found

include "php.h"

     ^~~~~~~

1 error generated. make: *** [conn.lo] Error 1 ERROR: `make' failed

I am following setup OS: MacOS Catalina 10.15.7 Framework: Xampp with php@7.3.26 & apache 2.4.46

Any help on above

yitam commented 3 years ago

Hi @dhirajranka I think you put your question under a totally different issue. For help with installing sqlsrv driver in Linux or macOS, please check the documentation Linux and macOS installation

If this does not help, please create a new issue.