PHP pdo_dblib extension fails to make and make install

Operating System & Version
CentOS 7
cPanel & WHM Version
11.92.0

deehslash

Member
Oct 22, 2019
6
1
3
Brazil
cPanel Access Level
DataCenter Provider
We are migrating a customer website to our cPanel infrastructure, and some specific parts of his website need to connect to an external Sybase database. In their current infrastructure, they are using PHP 7.3 with pdo_dblib extension integrated with FreeTDS to access that database.

We already have FreeTDS installed on the cPanel server, so let's jump to pdo_dblib installation.

EasyApache 4 web interface doesn't have the option to install pdo_dblib, neither Yum repository has this extension, so I need to manually install it.

I tried to download pdo_dblib with PECL using the following command:

Bash:
/opt/cpanel/ea-php73/root/usr/bin/pecl download pdo_dblib
I extracted the .tgz file, entered the folder, and ran the following commands to prepare the compilation (as I have done to other extensions not available in EasyApache 4 web interface):

Bash:
/opt/cpanel/ea-php73/root/usr/bin/phpize
./configure --with-php-config=/opt/cpanel/ea-php73/root/usr/bin/php-config
In the last command, it returns the following error:

Bash:
checking for PDO_DBLIB support via FreeTDS... yes, shared
configure: error: Cannot find FreeTDS in known installation directories
I could fix that, by specifying the --with-pdo-dblib parameter, as follows:

Bash:
./configure --with-pdo-dblib=/usr/local/freetds --with-php-config=/opt/cpanel/ea-php73/root/usr/bin/php-config
But, when I run makemake it returns this error:

Bash:
/root/PDO_DBLIB-1.0/pdo_dblib.c:37:1: error: unknown type name 'function_entry'
function_entry pdo_dblib_functions[] = {
^
/root/PDO_DBLIB-1.0/pdo_dblib.c:38:2: warning: braces around scalar initializer [enabled by default]
  {NULL, NULL, NULL}
  ^
/root/PDO_DBLIB-1.0/pdo_dblib.c:38:2: warning: (near initialization for 'pdo_dblib_functions[0]') [enabled by default]
/root/PDO_DBLIB-1.0/pdo_dblib.c:38:2: warning: initialization makes integer from pointer without a cast [enabled by default]
/root/PDO_DBLIB-1.0/pdo_dblib.c:38:2: warning: (near initialization for 'pdo_dblib_functions[0]') [enabled by default]
/root/PDO_DBLIB-1.0/pdo_dblib.c:38:2: warning: excess elements in scalar initializer [enabled by default]
/root/PDO_DBLIB-1.0/pdo_dblib.c:38:2: warning: (near initialization for 'pdo_dblib_functions[0]') [enabled by default]
/root/PDO_DBLIB-1.0/pdo_dblib.c:38:2: warning: excess elements in scalar initializer [enabled by default]
/root/PDO_DBLIB-1.0/pdo_dblib.c:38:2: warning: (near initialization for 'pdo_dblib_functions[0]') [enabled by default]
/root/PDO_DBLIB-1.0/pdo_dblib.c:62:2: warning: initialization from incompatible pointer type [enabled by default]
  pdo_dblib_functions,
  ^
/root/PDO_DBLIB-1.0/pdo_dblib.c:62:2: warning: (near initialization for 'pdo_dblib_module_entry.functions') [enabled by default]
/root/PDO_DBLIB-1.0/pdo_dblib.c: In function 'zm_startup_pdo_dblib':
/root/PDO_DBLIB-1.0/pdo_dblib.c:196:2: warning: passing argument 1 of 'dbmsghandle' from incompatible pointer type [enabled by default]
  dbmsghandle(msg_handler);
  ^
In file included from /usr/local/freetds/include/sybfront.h:23:0,
                 from /root/PDO_DBLIB-1.0/php_pdo_dblib_int.h:45,
                 from /root/PDO_DBLIB-1.0/pdo_dblib.c:32:
/usr/local/freetds/include/sybdb.h:599:13: note: expected 'MHANDLEFUNC' but argument is of type 'int (*)(struct DBPROCESS *, DBINT,  int,  int,  char *, char *, char *, DBUSMALLINT)'
MHANDLEFUNC dbmsghandle(MHANDLEFUNC handler);
             ^
make: *** [pdo_dblib.lo] Error 1
I've searched and found this post on cPanel forums saying that this extension looks like an older PECL module with no recent updates.

So instead of download it from PECL, I've downloaded the PHP 7.3.25 source from PHP official website, extracted the source, entered the ext/pdo_dblib/ directory, and ran the same commands as before. But now, make command return this error:

Bash:
/root/php-7.3.25/ext/pdo_dblib/dblib_stmt.c: In function 'pdo_dblib_stmt_should_stringify_col':
/root/php-7.3.25/ext/pdo_dblib/dblib_stmt.c:290:35: error: 'DBBIGINT' undeclared (first use in this function)
    if (sizeof(zend_long) < sizeof(DBBIGINT)) {
                                   ^
/root/php-7.3.25/ext/pdo_dblib/dblib_stmt.c:290:35: note: each undeclared identifier is reported only once for each function it appears in
In file included from /opt/cpanel/ea-php73/root/usr/include/php/Zend/zend.h:27:0,
                 from /opt/cpanel/ea-php73/root/usr/include/php/main/php.h:33,
                 from /root/php-7.3.25/ext/pdo_dblib/dblib_stmt.c:24:
/root/php-7.3.25/ext/pdo_dblib/dblib_stmt.c: In function 'pdo_dblib_stmt_get_col':
/root/php-7.3.25/ext/pdo_dblib/dblib_stmt.c:433:22: error: 'DBBIGINT' undeclared (first use in this function)
      ZVAL_LONG(zv, *(DBBIGINT *) data);
                      ^
/opt/cpanel/ea-php73/root/usr/include/php/Zend/zend_types.h:745:19: note: in definition of macro 'ZVAL_LONG'
   Z_LVAL_P(__z) = l;    \
                   ^
/root/php-7.3.25/ext/pdo_dblib/dblib_stmt.c:433:32: error: expected expression before ')' token
      ZVAL_LONG(zv, *(DBBIGINT *) data);
                                ^
/opt/cpanel/ea-php73/root/usr/include/php/Zend/zend_types.h:745:19: note: in definition of macro 'ZVAL_LONG'
   Z_LVAL_P(__z) = l;    \
                   ^
make: *** [dblib_stmt.lo] Error 1
I've searched a lot and couldn't find anything to help with this error. Worth mentioning that we tried to recompile FreeTDS with both --enable-msdblib and --enable-sybase-compat options, but that didn't change the make command output.

I also tried to ignore the errors with make -i, but when I ran make install a similar error was outputted. Even trying make install -i gave errors:

Bash:
make: [/root/php-7.3.25/ext/pdo_dblib/modules/pdo_dblib.la] Error 1 (ignored)
Installing shared extensions:     /opt/cpanel/ea-php73/root/usr/lib64/php/modules/
cp: cannot stat 'modules/*': No such file or directory
make: [install-modules] Error 1 (ignored)
 
Last edited by a moderator:

deehslash

Member
Oct 22, 2019
6
1
3
Brazil
cPanel Access Level
DataCenter Provider
That compilation problem was slowing the whole project down so I did something easier.

Remi PHP repository has the pdo_dblib extension already compiled for various PHP versions, so in another server (to not interfere with EasyApache PHP packages) I've downloaded PHP 7.3.25 (had to specify the version as in Remi repository it is already in 7.3.26) and pdo_dblib extension. Then I moved the .so file to the cPanel server, enabled it in the .ini, restarted PHP-FPM, and voilà, pdo_dblib was successfully loaded and working as expected.

In any case, if someone knows what is happening with the compilation process, please post it here so that it may help others with the same problem.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
15,139
2,405
363
cPanel Access Level
Root Administrator
Hey there!

I followed these same steps on my end and when I got to this point:

Code:
./configure --with-pdo-dblib=/usr/local/freetds --with-php-config=/opt/cpanel/ea-php73/root/usr/bin/php-config
I received the following error:

Code:
configure: error: Directory /usr/local/freetds is not a FreeTDS installation directory
Can you check your output from that command and see if you also received that message?
 

deehslash

Member
Oct 22, 2019
6
1
3
Brazil
cPanel Access Level
DataCenter Provider
Hey there!

I followed these same steps on my end and when I got to this point:

Code:
./configure --with-pdo-dblib=/usr/local/freetds --with-php-config=/opt/cpanel/ea-php73/root/usr/bin/php-config
I received the following error:

Code:
configure: error: Directory /usr/local/freetds is not a FreeTDS installation directory
Can you check your output from that command and see if you also received that message?
I didn't receive that message. I did not install FreeTDS through ea-freetds package, but I manually downloaded its source and compiled it, installing it to the /usr/local/freetds directory.

PS: Use --prefix option when configuring FreeTDS to specify the installation directory. Example: ./configure --prefix=/usr/local/freetds
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
15,139
2,405
363
cPanel Access Level
Root Administrator
Ah - that would be the difference then, as the cPanel install of FreeTDS doesn't use that directory path by default.

Since these are third-party packages I'm hesitant to say this is an issue with cPanel, as not every external package will work with EasyApache. I think the best thing to do in this case would be to submit a feature request using the link in my signature below to get that functionality added directly to the product.