PHP agent compilation error

Hello,

I am trying install PHP agent for APM and doing steps following documentation. https://github.com/elastic/apm-agent-php/blob/master/docs/setup.asciidoc

But it gives error when executing 'make' command.

[root@webapp ext]# make
/bin/sh /root/Downloads/apm-agent-php/src/ext/libtool --mode=compile cc  -I. -I/root/Downloads/apm-agent-php/src/ext -DPHP_ATOM_INC -I/root/Downloads/apm-agent-php/src/ext/include -I/root/Downloads/apm-agent-php/src/ext/main -I/root/Downloads/apm-agent-php/src/ext -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  -DHAVE_CONFIG_H  -std=c99   -c /root/Downloads/apm-agent-php/src/ext/elastic_apm_API.c -o elastic_apm_API.lo
libtool: compile:  cc -I. -I/root/Downloads/apm-agent-php/src/ext -DPHP_ATOM_INC -I/root/Downloads/apm-agent-php/src/ext/include -I/root/Downloads/apm-agent-php/src/ext/main -I/root/Downloads/apm-agent-php/src/ext -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 -DHAVE_CONFIG_H -std=c99 -c /root/Downloads/apm-agent-php/src/ext/elastic_apm_API.c  -fPIC -DPIC -o .libs/elastic_apm_API.o
In file included from /root/Downloads/apm-agent-php/src/ext/elastic_apm_API.c:18:0:
/root/Downloads/apm-agent-php/src/ext/numbered_intercepting_callbacks.h:1039:1: error: unknown type name 'zif_handler'
 static zif_handler g_numberedInterceptingCallback[ numberedInterceptingCallbacksCount ] =
 ^
/root/Downloads/apm-agent-php/src/ext/numbered_intercepting_callbacks.h:1041:17: warning: initialization makes integer from pointer without a cast [enabled by default]
                 [ 0 ] = ELASTIC_APM_NUMBERED_INTERCEPTING_CALLBACK_NAME( 0 ),
                 ^
    /root/Downloads/apm-agent-php/src/ext/numbered_intercepting_callbacks.h:1041:17: warning: (near initialization for 'g_numberedInterceptingCallback[0]') [enabled by default]
    /root/Downloads/apm-agent-php/src/ext/numbered_intercepting_callbacks.h:1041:17: error: initializer element is not computable at load time
    /root/Downloads/apm-agent-php/src/ext/numbered_intercepting_callbacks.h:1041:17: error: (near initialization for 'g_numberedInterceptingCallback[0]')
    /root/Downloads/apm-agent-php/src/ext/numbered_intercepting_callbacks.h:1042:17: warning: initialization makes integer from pointer without a cast [enabled by default]
                     [ 1 ] = ELASTIC_APM_NUMBERED_INTERCEPTING_CALLBACK_NAME( 1 ),
                     ^
    /root/Downloads/apm-agent-php/src/ext/numbered_intercepting_callbacks.h:1042:17: warning: (near initialization for 'g_numberedInterceptingCallback[1]') [enabled by default]
    /root/Downloads/apm-agent-php/src/ext/numbered_intercepting_callbacks.h:1042:17: error: initializer element is not computable at load time
    /root/Downloads/apm-agent-php/src/ext/numbered_intercepting_callbacks.h:1042:17: error: (near initialization for 'g_numberedInterceptingCallback[1]')
    /root/Downloads/apm-agent-php/src/ext/numbered_intercepting_callbacks.h:1043:17: warning: initialization makes integer from pointer without a cast [enabled by default]
                     [ 2 ] = ELASTIC_APM_NUMBERED_INTERCEPTING_CALLBACK_NAME( 2 ),
                     ^
    /root/Downloads/apm-agent-php/src/ext/numbered_intercepting_callbacks.h:1043:17: warning: (near initialization for 'g_numberedInterceptingCallback[2]') [enabled by default]
    /root/Downloads/apm-agent-php/src/ext/numbered_intercepting_callbacks.h:1043:17: error: initializer element is not computable at load time
    /root/Downloads/apm-agent-php/src/ext/numbered_intercepting_callbacks.h:1043:17: error: (near initialization for 'g_numberedInterceptingCallback[2]')
    /root/Downloads/apm-agent-php/src/ext/numbered_intercepting_callbacks.h:1044:17: warning: initialization makes integer from pointer without a cast [enabled by default]
     [ 3 ] = ELASTIC_APM_NUMBERED_INTERCEPTING_CALLBACK_NAME( 3 )
/root/Downloads/apm-agent-php/src/ext/elastic_apm_API.c:66:1: error: unknown type name 'zif_handler'
 static zif_handler g_interceptedCallOriginalHandler = NULL;
 ^
In file included from /root/Downloads/apm-agent-php/src/ext/StringView.h:16:0,
                 from /root/Downloads/apm-agent-php/src/ext/elastic_apm_API.h:17,
                 from /root/Downloads/apm-agent-php/src/ext/elastic_apm_API.c:12:
/root/Downloads/apm-agent-php/src/ext/elastic_apm_API.c: In function 'internalFunctionCallInterceptingImpl':
/root/Downloads/apm-agent-php/src/ext/elastic_apm_API.c:74:57: warning: comparison between pointer and integer [enabled by default]
     ELASTIC_APM_ASSERT(g_interceptedCallOriginalHandler == NULL, "");
                                                         ^
/root/Downloads/apm-agent-php/src/ext/elastic_apm_assert.h:100:56: note: in definition of macro 'ELASTIC_APM_ASSERT_WITH_LEVEL'
         if ( getGlobalAssertLevel() >= (level) && ( ! (cond) ) ) \
                                                        ^
/root/Downloads/apm-agent-php/src/ext/elastic_apm_API.c:74:5: note: in expansion of macro 'ELASTIC_APM_ASSERT'
     ELASTIC_APM_ASSERT(g_interceptedCallOriginalHandler == NULL, "");
     ^
/root/Downloads/apm-agent-php/src/ext/elastic_apm_API.c:81:38: warning: assignment makes integer from pointer without a cast [enabled by default]
     g_interceptedCallOriginalHandler = NULL;
                                      ^
/root/Downloads/apm-agent-php/src/ext/elastic_apm_API.c: In function 'resetCallInterceptionOnRequestShutdown':
/root/Downloads/apm-agent-php/src/ext/elastic_apm_API.c:95:52: warning: assignment makes pointer from integer without a cast [enabled by default]
         data->funcEntry->internal_function.handler = data->originalHandler;
                                                    ^
/root/Downloads/apm-agent-php/src/ext/elastic_apm_API.c: In function 'addToFunctionsToInterceptData':
/root/Downloads/apm-agent-php/src/ext/elastic_apm_API.c:113:76: warning: assignment makes integer from pointer without a cast [enabled by default]
     g_functionsToInterceptData[ *interceptRegistrationId ].originalHandler = funcEntry->internal_function.handler;
                                                                            ^
/root/Downloads/apm-agent-php/src/ext/elastic_apm_API.c:114:42: warning: assignment makes pointer from integer without a cast [enabled by default]
     funcEntry->internal_function.handler = g_numberedInterceptingCallback[ *interceptRegistrationId ];
                                          ^
In file included from /root/Downloads/apm-agent-php/src/ext/StringView.h:16:0,
                 from /root/Downloads/apm-agent-php/src/ext/elastic_apm_API.h:17,
                 from /root/Downloads/apm-agent-php/src/ext/elastic_apm_API.c:12:
/root/Downloads/apm-agent-php/src/ext/elastic_apm_API.c: In function 'elasticApmCallInterceptedOriginal':
/root/Downloads/apm-agent-php/src/ext/elastic_apm_API.c:202:57: warning: comparison between pointer and integer [enabled by default]
     ELASTIC_APM_ASSERT(g_interceptedCallOriginalHandler != NULL, "");
                                                         ^
/root/Downloads/apm-agent-php/src/ext/elastic_apm_assert.h:100:56: note: in definition of macro 'ELASTIC_APM_ASSERT_WITH_LEVEL'
         if ( getGlobalAssertLevel() >= (level) && ( ! (cond) ) ) \
                                                        ^
/root/Downloads/apm-agent-php/src/ext/elastic_apm_API.c:202:5: note: in expansion of macro 'ELASTIC_APM_ASSERT'
     ELASTIC_APM_ASSERT(g_interceptedCallOriginalHandler != NULL, "");
     ^
/root/Downloads/apm-agent-php/src/ext/elastic_apm_API.c:204:37: error: called object 'g_interceptedCallOriginalHandler' is not a function or function pointer
     g_interceptedCallOriginalHandler( g_interceptedCallZendExecuteData, return_value );
                                     ^
/root/Downloads/apm-agent-php/src/ext/elastic_apm_API.c:66:20: note: declared here
 static zif_handler g_interceptedCallOriginalHandler = NULL;
                    ^
make: *** [elastic_apm_API.lo] Error 1

Environment details:

[root@webapp ext]# cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)


[root@webapp ext]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
1 Like

Hi @tumenzul - welcome to the forum!

What PHP version do you use? Is it possible that the root cause is the same as at https://github.com/elastic/apm-agent-php/issues/124?

I am using 7.1.33. This issue same as me.

Thank you @Sergey_Kleyman

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.