(This is a follow-up of Detect library in Makefile.PL).

I would like to use Devel::CheckLib to check that a number of PHP header files (e.g. php_main.h) are present:

use strict; use warnings; use Devel::CheckLib; our $debug ||= 0; my @headers = qw ( php_main.h ); my @incpath = qw( /usr/local/include /usr/local/include/php /usr/local/include/php/main /usr/local/include/php/TSRM /usr/local/include/php/Zend /usr/local/include/php/ext /usr/local/include/php/ext/date/lib ); check_lib_or_exit( header => \@headers, incpath => \@incpath, debug => $debug, ); __END__ $ perl -s check.pl -debug 1 | head -20 # /usr/bin/cc assertlibFY1Ue6D2.c -I/usr/local/include -I/usr/local/in +clude/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/lo +cal/include/php/ext/date/lib -o assertlibZUeAsG6l In file included from /usr/local/include/php/Zend/zend_globals.h:28, from /usr/local/include/php/main/php_main.h:25, from assertlibFY1Ue6D2.c:1: /usr/local/include/php/Zend/zend_globals_macros.h: In function ‘BEGIN_ +EXTERN_C’: /usr/local/include/php/Zend/zend_globals_macros.h:37: error: expected +‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘struct’ /usr/local/include/php/Zend/zend_globals_macros.h:47: error: expected +‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘zend_executor_globals +’ /usr/local/include/php/Zend/zend_globals_macros.h:56: error: expected +‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘zend_scanner_globals’ /usr/local/include/php/Zend/zend_globals_macros.h:66: error: expected +‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘zend_scanner_globals’ /usr/local/include/php/Zend/zend_globals_macros.h:69: error: expected +declaration specifiers before ‘END_EXTERN_C’
The problem is that the compilation of the header file above apparently need some compiler flags or other options set in order to be successful. To say that the PHP build process is difficult is an understatement. Any light into how, if at all possible, to use Devel::CheckLib in this context is highly appreciated.

Update: As suggested by Anonymous Monk my problem boils down to how to make the following compile:

$ cat foo.c #include <php_main.h> int main(void) { return 0; } $ /usr/bin/gcc foo.c -I/usr/local/include -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/p +hp/ext/date/lib -o foo
Devel::CheckLib adds platform independence, but making it compile on at least one platform would be a good start. ENV:
gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu3) Linux 2.6.24-22-generic #1 SMP Mon Nov 24 18:32:42 UTC 2008 i686 GNU/L +inux This is perl, v5.8.8 built for i486-linux-gnu-thread-multi PHP 5.2.6 (cli) Zend Engine v2.2.0
--
No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. [1]

In reply to Use Devel::CheckLib to check for PHP dependencies by andreas1234567

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.