php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79690 compile error: 'LOCK_EX' undeclared
Submitted: 2020-06-11 17:23 UTC Modified: 2020-06-12 15:31 UTC
From: jakemoote at gmail dot com Assigned:
Status: Closed Package: dbase (PECL)
PHP Version: 7.4.7 OS: Alpine Linux 3.11
Private report: No CVE-ID: None
 [2020-06-11 17:23 UTC] jakemoote at gmail dot com
Description:
------------
Same issue as https://bugs.php.net/bug.php?id=78594
However the fix http://svn.php.net/viewvc/?view=revision&revision=348188 does not seem to work in docker alpine containers due to HAVE_SYS_FILE_H not being defined

Removing the #ifdef HAVE_SYS_FILE_H but leaving # include <sys/file.h> makes the extension compile and install correctly

/usr/include/sys/file.h does exist

Test script:
---------------
docker run -it php:7.4-fpm-alpine /bin/sh
apk add $PHPIZE_DEPS
pecl install dbase

Expected result:
----------------
dbase compiles and installs

Actual result:
--------------
creating libtool
appending configuration tag "CXX" to libtool
configure: patching config.h.in
configure: creating ./config.status
config.status: creating config.h
running: make
/bin/sh /tmp/pear/temp/pear-build-defaultuserLgNcJN/dbase-7.0.1/libtool --mode=compile cc  -I. -I/tmp/pear/temp/dbase -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-defaultuserLgNcJN/dbase-7.0.1/include -I/tmp/pear/temp/pear-build-defaultuserLgNcJN/dbase-7.0.1/main -I/tmp/pear/temp/dbase -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /tmp/pear/temp/dbase/dbf_head.c -o dbf_head.lo
mkdir .libs
 cc -I. -I/tmp/pear/temp/dbase -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-defaultuserLgNcJN/dbase-7.0.1/include -I/tmp/pear/temp/pear-build-defaultuserLgNcJN/dbase-7.0.1/main -I/tmp/pear/temp/dbase -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/dbase/dbf_head.c  -fPIC -DPIC -o .libs/dbf_head.o
/tmp/pear/temp/dbase/dbf_head.c: In function 'dbf_open':
/tmp/pear/temp/dbase/dbf_head.c:346:41: error: 'LOCK_EX' undeclared (first use in this function)
  346 |  if (php_flock(fd, (o_flags == O_RDWR ? LOCK_EX : LOCK_SH))) {
      |                                         ^~~~~~~
/tmp/pear/temp/dbase/dbf_head.c:346:41: note: each undeclared identifier is reported only once for each function it appears in
/tmp/pear/temp/dbase/dbf_head.c:346:51: error: 'LOCK_SH' undeclared (first use in this function)
  346 |  if (php_flock(fd, (o_flags == O_RDWR ? LOCK_EX : LOCK_SH))) {
      |                                                   ^~~~~~~
/tmp/pear/temp/dbase/dbf_head.c:352:17: error: 'LOCK_UN' undeclared (first use in this function)
  352 |   php_flock(fd, LOCK_UN);
      |                 ^~~~~~~
make: *** [Makefile:191: dbf_head.lo] Error 1
ERROR: `make' failed

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-06-12 15:31 UTC] jakemoote at gmail dot com
-Status: Open +Status: Closed
 [2020-06-12 15:31 UTC] jakemoote at gmail dot com
Nevermind, I figured out how to properly set the HAVE_SYS_FILE_H flag.

Full working example:
docker run -it php:7.4-fpm-alpine /bin/sh
apk add $PHPIZE_DEPS
pecl download dbase
tar xzf dbase-7.0.1.tgz
cd dbase-7.0.1
phpize
CPPFLAGS=HAVE_SYS_FILE_H ./configure
make
make install
 [2020-06-12 15:38 UTC] jakemoote at gmail dot com
Posted the incorrect configure command for the fix:

CPPFLAGS="-DHAVE_SYS_FILE_H" ./configure

is the correct command
 [2020-06-12 15:52 UTC] jakemoote at gmail dot com
Here is an even simpler command to deal with this:

CPPFLAGS="-DHAVE_SYS_FILE_H" pecl install dbase

This whole "bug" ticket was really just due to my lack of understanding of how pecl worked and compiling extensions
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 23 03:01:28 2024 UTC