Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile failure on php 7.4 #355

Closed
monteiro opened this issue Dec 2, 2019 · 11 comments
Closed

Compile failure on php 7.4 #355

monteiro opened this issue Dec 2, 2019 · 11 comments

Comments

@monteiro
Copy link

monteiro commented Dec 2, 2019

After installing php 7.4 and run:

pecl install amqp

I got some compilation errors.

running: make
/bin/sh /private/tmp/pear/temp/pear-build-hugoqKJyG7/amqp-1.9.4/libtool --mode=compile cc  -I. -I/private/tmp/pear/temp/amqp -DPHP_ATOM_INC -I/private/tmp/pear/temp/pear-build-hugoqKJyG7/amqp-1.9.4/include -I/private/tmp/pear/temp/pear-build-hugoqKJyG7/amqp-1.9.4/main -I/private/tmp/pear/temp/amqp -I/usr/local/Cellar/php/7.4.0/include/php -I/usr/local/Cellar/php/7.4.0/include/php/main -I/usr/local/Cellar/php/7.4.0/include/php/TSRM -I/usr/local/Cellar/php/7.4.0/include/php/Zend -I/usr/local/Cellar/php/7.4.0/include/php/ext -I/usr/local/Cellar/php/7.4.0/include/php/ext/date/lib -I/usr/local/Cellar/rabbitmq-c/0.9.0_1/include  -DHAVE_CONFIG_H  -g -O2   -c /private/tmp/pear/temp/amqp/amqp.c -o amqp.lo
mkdir .libs
 cc -I. -I/private/tmp/pear/temp/amqp -DPHP_ATOM_INC -I/private/tmp/pear/temp/pear-build-hugoqKJyG7/amqp-1.9.4/include -I/private/tmp/pear/temp/pear-build-hugoqKJyG7/amqp-1.9.4/main -I/private/tmp/pear/temp/amqp -I/usr/local/Cellar/php/7.4.0/include/php -I/usr/local/Cellar/php/7.4.0/include/php/main -I/usr/local/Cellar/php/7.4.0/include/php/TSRM -I/usr/local/Cellar/php/7.4.0/include/php/Zend -I/usr/local/Cellar/php/7.4.0/include/php/ext -I/usr/local/Cellar/php/7.4.0/include/php/ext/date/lib -I/usr/local/Cellar/rabbitmq-c/0.9.0_1/include -DHAVE_CONFIG_H -g -O2 -c /private/tmp/pear/temp/amqp/amqp.c  -fno-common -DPIC -o .libs/amqp.o
/bin/sh /private/tmp/pear/temp/pear-build-hugoqKJyG7/amqp-1.9.4/libtool --mode=compile cc  -I. -I/private/tmp/pear/temp/amqp -DPHP_ATOM_INC -I/private/tmp/pear/temp/pear-build-hugoqKJyG7/amqp-1.9.4/include -I/private/tmp/pear/temp/pear-build-hugoqKJyG7/amqp-1.9.4/main -I/private/tmp/pear/temp/amqp -I/usr/local/Cellar/php/7.4.0/include/php -I/usr/local/Cellar/php/7.4.0/include/php/main -I/usr/local/Cellar/php/7.4.0/include/php/TSRM -I/usr/local/Cellar/php/7.4.0/include/php/Zend -I/usr/local/Cellar/php/7.4.0/include/php/ext -I/usr/local/Cellar/php/7.4.0/include/php/ext/date/lib -I/usr/local/Cellar/rabbitmq-c/0.9.0_1/include  -DHAVE_CONFIG_H  -g -O2   -c /private/tmp/pear/temp/amqp/amqp_type.c -o amqp_type.lo
 cc -I. -I/private/tmp/pear/temp/amqp -DPHP_ATOM_INC -I/private/tmp/pear/temp/pear-build-hugoqKJyG7/amqp-1.9.4/include -I/private/tmp/pear/temp/pear-build-hugoqKJyG7/amqp-1.9.4/main -I/private/tmp/pear/temp/amqp -I/usr/local/Cellar/php/7.4.0/include/php -I/usr/local/Cellar/php/7.4.0/include/php/main -I/usr/local/Cellar/php/7.4.0/include/php/TSRM -I/usr/local/Cellar/php/7.4.0/include/php/Zend -I/usr/local/Cellar/php/7.4.0/include/php/ext -I/usr/local/Cellar/php/7.4.0/include/php/ext/date/lib -I/usr/local/Cellar/rabbitmq-c/0.9.0_1/include -DHAVE_CONFIG_H -g -O2 -c /private/tmp/pear/temp/amqp/amqp_type.c  -fno-common -DPIC -o .libs/amqp_type.o
/private/tmp/pear/temp/amqp/amqp_type.c:87:7: error: expected ';' after expression
        ulong index;
             ^
             ;
/private/tmp/pear/temp/amqp/amqp_type.c:87:2: error: use of undeclared identifier 'ulong'
        ulong index;
        ^
/private/tmp/pear/temp/amqp/amqp_type.c:92:2: error: non-object type 'char *(const char *, int)' is not assignable
        PHP5to7_ZEND_HASH_FOREACH_KEY_VAL(ht, index, real_key, key, key_len, data, value, pos) {
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/private/tmp/pear/temp/amqp/php7_support.h:78:3: note: expanded from macro 'PHP5to7_ZEND_HASH_FOREACH_KEY_VAL'
  ZEND_HASH_FOREACH_KEY_VAL((ht), (num_key), (real_key), (val))
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/php/7.4.0/include/php/Zend/zend_hash.h:1005:5: note: expanded from macro 'ZEND_HASH_FOREACH_KEY_VAL'
        _h = _p->h; \
        ~~ ^
/private/tmp/pear/temp/amqp/amqp_type.c:87:8: warning: expression result unused [-Wunused-value]
        ulong index;
              ^~~~~
/private/tmp/pear/temp/amqp/amqp_type.c:122:7: error: expected ';' after expression
        ulong index;
             ^
             ;
/private/tmp/pear/temp/amqp/amqp_type.c:122:2: error: use of undeclared identifier 'ulong'
        ulong index;
        ^
/private/tmp/pear/temp/amqp/amqp_type.c:130:2: error: non-object type 'char *(const char *, int)' is not assignable
        PHP5to7_ZEND_HASH_FOREACH_KEY_VAL(ht, index, real_key, key, key_len, data, value, pos) {
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/private/tmp/pear/temp/amqp/php7_support.h:78:3: note: expanded from macro 'PHP5to7_ZEND_HASH_FOREACH_KEY_VAL'
  ZEND_HASH_FOREACH_KEY_VAL((ht), (num_key), (real_key), (val))
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/php/7.4.0/include/php/Zend/zend_hash.h:1005:5: note: expanded from macro 'ZEND_HASH_FOREACH_KEY_VAL'
        _h = _p->h; \
        ~~ ^
/private/tmp/pear/temp/amqp/amqp_type.c:143:35: warning: format specifies type 'unsigned long' but the argument has type 'char *(*)(const char *, int)' [-Wformat]
                                key_len = sprintf(str, "%lu", index);
                                                        ~~~   ^~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/secure/_stdio.h:47:56: note: expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
                                                       ^~~~~~~~~~~
/private/tmp/pear/temp/amqp/amqp_type.c:147:91: warning: format specifies type 'unsigned long' but the argument has type 'char *(*)(const char *, int)' [-Wformat]
                                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Ignoring non-string header field '%lu'", index);
                                                                                                               ~~~    ^~~~~
/private/tmp/pear/temp/amqp/amqp_type.c:122:8: warning: expression result unused [-Wunused-value]
        ulong index;
              ^~~~~
/private/tmp/pear/temp/amqp/amqp_type.c:185:7: error: expected ';' after expression
        ulong index;
             ^
             ;
/private/tmp/pear/temp/amqp/amqp_type.c:185:2: error: use of undeclared identifier 'ulong'
        ulong index;
        ^
/private/tmp/pear/temp/amqp/amqp_type.c:195:2: error: non-object type 'char *(const char *, int)' is not assignable
        PHP5to7_ZEND_HASH_FOREACH_KEY_VAL(ht, index, real_key, key, key_len, data, value, pos) {
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/private/tmp/pear/temp/amqp/php7_support.h:78:3: note: expanded from macro 'PHP5to7_ZEND_HASH_FOREACH_KEY_VAL'
  ZEND_HASH_FOREACH_KEY_VAL((ht), (num_key), (real_key), (val))
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/php/7.4.0/include/php/Zend/zend_hash.h:1005:5: note: expanded from macro 'ZEND_HASH_FOREACH_KEY_VAL'
        _h = _p->h; \
        ~~ ^
/private/tmp/pear/temp/amqp/amqp_type.c:185:8: warning: expression result unused [-Wunused-value]
        ulong index;
              ^~~~~
5 warnings and 9 errors generated.
make: *** [amqp_type.lo] Error 1
ERROR: `make' failed
@signor-pedro
Copy link

I have the same problem

@marartner
Copy link

same here!

@panosru
Copy link

panosru commented Dec 9, 2019

diff --git a/a/amqp_type.c b/b/amqp_type.c
index 60518f9..2080ccc 100644
--- a/a/amqp_type.c
+++ b/b/amqp_type.c
@@ -84,7 +84,7 @@ void php_amqp_type_internal_convert_zval_array(zval *php_array, amqp_field_value
 	char *key;
 	uint key_len;
 
-	ulong index;
+	zend_ulong index;
 	ht = Z_ARRVAL_P(php_array);
 
 	zend_bool is_amqp_array = 1;
@@ -119,7 +119,7 @@ void php_amqp_type_internal_convert_zval_to_amqp_table(zval *php_array, amqp_tab
 	char *key;
 	uint key_len;
 
-	ulong index;
+	zend_ulong index;
 
 
 	ht = Z_ARRVAL_P(php_array);
@@ -182,7 +182,7 @@ void php_amqp_type_internal_convert_zval_to_amqp_array(zval *zvalArguments, amqp
 	char *key;
 	uint key_len;
 
-	ulong index;
+	zend_ulong index;
 
 	char type[16];
 

If you are on macOS then you need to run brew install rabbitmq-c, after than run brew info rabbitmq-c, it will output something like this:

rabbitmq-c: stable 0.10.0 (bottled), HEAD
RabbitMQ C client
https://github.com/alanxz/rabbitmq-c
/usr/local/Cellar/rabbitmq-c/0.10.0 (20 files, 489.4KB) *
  Poured from bottle on 2019-12-05 at 00:42:00
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/rabbitmq-c.rb
==> Dependencies
Build: cmake, pkg-config
Required: openssl@1.1, popt
==> Options
--HEAD
	Install HEAD version
==> Analytics
install: 595 (30 days), 1,544 (90 days), 4,720 (365 days)
install-on-request: 473 (30 days), 1,238 (90 days), 3,853 (365 days)
build-error: 0 (30 days)

then you can build amqp like this:

# git clone https://github.com/pdezwart/php-amqp.git
# phpize
# ./configure --with-librabbitmq-dir=/usr/local/Cellar/rabbitmq-c/0.10.0
# make && make install

Then you just add extension=amqp to your php.ini, restart your php service and you are good to go:
image
image

Keep in mind, this will download the latest commit in master. To wit: I have v1.9.5-dev; if you need the latest stable release, before phpize you have to run git checkout tags/v1.9.4 ./ where v1.9.4 will be equivalent to the current latest stable release at the time you read this.

@ahilles107
Copy link
Contributor

I forked master and applied those changes to my fork. You can use it with phpbrew like that: phpbrew ext install github:ahilles107/php-amqp

@cmb69
Copy link
Contributor

cmb69 commented Dec 11, 2019

For reference: php/php-src@bebcdcc

@Nyholm
Copy link

Nyholm commented Jan 2, 2020

Thank you @panosru for the fix.

I can confirm that it is working.

@lstrojny
Copy link
Collaborator

lstrojny commented Jan 2, 2020

@ahilles107 could you open a PR?

cmb69 added a commit to cmb69/php-amqp that referenced this issue Jan 2, 2020
As of PHP 7.4.0, portable definitions of `ulong` and `uint` are no
longer available.  Therefore we replace `uint` with `unsigned`, and
`ulong` with `zend_ulong`.
cmb69 added a commit to cmb69/php-amqp that referenced this issue Jan 2, 2020
As of PHP 7.4.0, portable definitions of `ulong` and `uint` are no
longer available.  Therefore we replace `uint` with `unsigned`, and
`ulong` with `zend_ulong`.
@ahilles107
Copy link
Contributor

I can but i see that @cmb69 have even better fix in his fork.

@cmb69
Copy link
Contributor

cmb69 commented Jan 2, 2020

To clarify: the uintunsigned replacement is necessary for Windows (at least).

@renedelima
Copy link

If you are on macOS then you need to run brew install rabbitmq-c, after than run brew info rabbitmq-c, it will output something like this:

rabbitmq-c: stable 0.10.0 (bottled), HEAD
RabbitMQ C client
https://github.com/alanxz/rabbitmq-c
/usr/local/Cellar/rabbitmq-c/0.10.0 (20 files, 489.4KB) *
Poured from bottle on 2019-12-05 at 00:42:00
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/rabbitmq-c.rb
=> Dependencies
Build: cmake, pkg-config
Required: openssl@1.1, popt
=> Options
--HEAD
Install HEAD version
=> Analytics
install: 595 (30 days), 1,544 (90 days), 4,720 (365 days)
install-on-request: 473 (30 days), 1,238 (90 days), 3,853 (365 days)
build-error: 0 (30 days)

then you can build amqp like this:

git clone https://github.com/pdezwart/php-amqp.git
phpize
./configure --with-librabbitmq-dir=/usr/local/Cellar/rabbitmq-c/0.10.0
make && make install

Perfect. It worked on macOS 10.15.2. Thank you @panosru!

@anoopd
Copy link

anoopd commented Jan 9, 2021

@renedelima Shouldn't we cd to php-amqp before phpize ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants