<!-- $Revision: 1.3 $ --> <chapter id="faq.build"> <title>Build Problems</title> <titleabbrev>Build Problems</titleabbrev> <para> This section gathers most common errors that occur at build time. </para> <qandaset> <qandaentry id="faq.build.configure"> <question> <para> I got the latest version of PHP using the anonymous CVS service, but there's no configure script! </para> </question> <answer> <para> You have to have the GNU autoconf package installed so you can generate the configure script from configure.in. Just run <command>./buildconf</command> in the top-level directory after getting the sources from the CVS server. (Also, unless you run configure with the <literal>--enable-maintainer-mode</literal> option, the configure script will not automatically get rebuilt when the configure.in file is updated, so you should make sure to do that manually when you notice configure.in has changed. One symptom of this is finding things like @VARIABLE@ in your Makefile after configure or config.status is run.) </para> </answer> </qandaentry> <qandaentry id="faq.build.configuring"> <question> <para> I'm having problems configuring PHP to work with Apache. It says it can't find httpd.h, but it's right where I said it is! </para> </question> <answer> <para> You need to tell the configure/setup script the location of the top-level of your Apache source tree. This means that you want to specify '<literal>--with-apache=/path/to/apache</literal>' and <emphasis>not</emphasis> '<literal>--with-apache=/path/to/apache/src</literal>'. </para> </answer> </qandaentry> <qandaentry id="faq.build.not_found"> <question> <para> When I run configure, it says that it can't find the include files or library for GD, gdbm, or some other package! </para> </question> <answer> <para> You can make the configure script looks for header files and libraries in non-standard locations by specifying additional flags to pass to the C preprocessor and linker, such as: <programlisting> CPPFLAGS=-I/path/to/include LDFLAGS=-L/path/to/library ./configure </programlisting> If you're using a csh-variant for your login shell (why?), it would be: <programlisting> env CPPFLAGS=-I/path/to/include LDFLAGS=-L/path/to/library ./configure </programlisting> </para> </answer> </qandaentry> <qandaentry id="faq.build.yytname"> <question> <para> When it is compiling the file language-parser.tab.c, it gives me errors that say 'yytname undeclared'. </para> </question> <answer> <para> You need to update your version of Bison. You can find the latest version at <ulink url="&faqurl.bison;">&faqurl.bison;</ulink>. </para> </answer> </qandaentry> <qandaentry id="faq.build.link"> <question> <para> When I run 'make', it seems to run fine but then fails when it tries to link the final application complaining that it can't find some files. </para> </question> <answer> <para> Some old versions of make that don't correctly put the compiled versions of the files in the functions directory into that same directory. Try running "<command>cp *.o functions</command>" and then re-running '<command>make</command>' to see if that helps. If it does, you should really upgrade to a recent version of GNU make. </para> </answer> </qandaentry> <qandaentry id="faq.build.undefined"> <question> <para> When linking PHP, it complains about a number of undefined references. </para> </question> <answer> <para> Take a look at the link line and make sure that all of the appropriate libraries are being included at the end. Common ones that you might have missed are '-ldl' and any libraries required for any database support you included. </para> <para> If you're linking with Apache 1.2.x, did you remember to add the appropriate information to the EXTRA_LIBS line of the Configuration file and re-rerun Apache's Configure script? See the <ulink url="&faqurl.file.installation;">INSTALL</ulink> file that comes with the distribution for more information. </para> <para> Some people have also reported that they had to add '-ldl' immediately following '<filename>libphp3.a</filename>' when linking with Apache. </para> </answer> </qandaentry> <qandaentry id="faq.build.Apache"> <question> <para> I can't figure out how to build PHP with Apache 1.3. </para> </question> <answer> <para> This is actually quite easy. Follow these steps carefully: <itemizedlist> <listitem> <simpara> Grab the latest Apache 1.3 distribution from <ulink url="&faqurl.apache;">&faqurl.apache;</ulink>. </simpara> </listitem> <listitem> <simpara> Ungzip and untar it somewhere, for example <filename>/usr/local/src/apache-1.3</filename>. </simpara> </listitem> <listitem> <simpara> Compile PHP by first running <command>./configure --with-apache=/<path>/apache-1.3</command> (substitute <path> for the actual path to your apache-1.3 directory. </simpara> </listitem> <listitem> <simpara> Type '<literal>make</literal>' followed by '<literal>make install</literal>' to build PHP and copy the necessary files to the Apache distribution tree. </simpara> </listitem> <listitem> <simpara> Change directories into to your <filename>/<path>/apache-1.3/src</filename> directory and edit the <filename>Configuration</filename> file. At the end of the file, add: <literal>AddModule modules/php3/libphp3.a</literal>. </simpara> </listitem> <listitem> <simpara> Type: '<command>./Configure</command>' followed by '<literal>make</literal>'. </simpara> </listitem> <listitem> <simpara> You should now have a PHP-enabled httpd binary! </simpara> </listitem> </itemizedlist> </para> <para> <emphasis>Note:</emphasis> : You can also use the new Apache <literal>./configure</literal> script. See the instructions in the <literal>README.configure</literal> file which is part of your Apache distribution. Also have a look at the <filename>INSTALL</filename> file in the PHP distribution. </para> </answer> </qandaentry> <qandaentry id="faq.build.not_running"> <question> <para> I have followed all the steps to install the Apache module version on UNIX, and my PHP scripts show up in my browser or I am being asked to save the file. </para> </question> <answer> <para> This means that the PHP module is not getting invoked for some reason. Three things to check before asking for further help: <itemizedlist> <listitem> <simpara> Make sure that the httpd binary you are running is the actual new httpd binary you just built. To do this, try running: <literal>/path/to/binary/httpd -l</literal> </simpara> <simpara> If you don't see <filename>mod_php3.c</filename> listed then you are not running the right binary. Find and install the correct binary. </simpara> </listitem> <listitem> <simpara> Make sure you have added the correct Mime Type to one of your <literal>Apache .conf</literal> files. It should be: <literal>AddType application/x-httpd-php3 .php3</literal> (for PHP 3) </simpara> <simpara> or <literal>AddType application/x-httpd-php .php</literal> (for PHP 4) </simpara> <simpara> Also make sure that this AddType line is not hidden away inside a <Virtualhost> or <Directory> block which would prevent it from applying to the location of your test script. </simpara> </listitem> <listitem> <simpara> Finally, the default location of the Apache configuration files changed between Apache 1.2 and Apache 1.3. You should check to make sure that the configuration file you are adding the AddType line to is actually being read. You can put an obvious syntax error into your httpd.conf file or some other obvious change that will tell you if the file is being read correctly. </simpara> </listitem> </itemizedlist> </para> </answer> </qandaentry> <qandaentry id="faq.build.activate_module"> <question> <para> It says to use: <literal>--activate-module=src/modules/php4/libphp4.a</literal>, but that file doesn't exist, so I changed it to <literal>--activate-module=src/modules/php4/libmodphp4.a</literal> and it doesn't work!? What's going on? </para> </question> <answer> <para> Well, you decided to try to outsmart the people who wrote those nice step-by-step instructions for you and you have now discovered that these people cannot be outsmarted. The libphp4.a file is not supposed to exist. The Apache build process will create it. </para> </answer> </qandaentry> <qandaentry id="faq.build.ansi"> <question> <para> When I try to build Apache with PHP as a static module using <literal>--activate-module=src/modules/php4/libphp4.a</literal> it tells me that my compiler is not ANSI compliant. </para> </question> <answer> <para> This is a misleading error message from Apache that has been fixed in more recent versions. </para> </answer> </qandaentry> <qandaentry id="faq.build.apxs"> <question> <para> When I try to build PHP using <literal>--with-apxs</literal> I get strange error messages. </para> </question> <answer> <para> There are three things to check here. First, for some reason when Apache builds the apxs Perl script, it sometimes ends up getting built without the proper compiler and flags variables. Edit your apxs (sometimes found in /usr/local/apache/bin/apxs or /usr/sbin/apxs) and check for these lines: <programlisting> my $CFG_CFLAGS_SHLIB = ' '; # substituted via Makefile.tmpl my $CFG_LD_SHLIB = ' '; # substituted via Makefile.tmpl my $CFG_LDFLAGS_SHLIB = ' '; # substituted via Makefile.tmpl </programlisting> If this is what you see, you have found your problem. Change these lines to say: <programlisting> my $CFG_CFLAGS_SHLIB = '-fpic -DSHARED_MODULE'; # substituted via Makefile.tmpl my $CFG_LD_SHLIB = 'gcc'; # substituted via Makefile.tmpl my $CFG_LDFLAGS_SHLIB = q(-shared);# substituted via Makefile.tmpl </programlisting> The second possible problem should only be an issue on RedHat-6.1/6.2. The apxs script RedHat ships is broken. Look for this line: <programlisting> my $CFG_LIBEXECDIR = 'modules'; # substituted via APACI install </programlisting> If you see the above line, change it to this: <programlisting> my $CFG_LIBEXECDIR = '/usr/lib/apache'; # substituted via APACI install </programlisting> Last, if you reconfigure/reinstall Apache, add a 'make clean' to the process after './configure' and before 'make'. </para> </answer> </qandaentry> <qandaentry id="faq.build.microtime"> <question> <para> During 'make', I get errors in microtime, and a lot of 'RUSAGE_' stuff. </para> </question> <answer> <para> During the 'make' portion of installation, if you encounter problems that look similar to this: <programlisting> microtime.c: In function `php_if_getrusage': microtime.c:94: storage size of `usg' isn't known microtime.c:97: `RUSAGE_SELF' undeclared (first use in this function) microtime.c:97: (Each undeclared identifier is reported only once microtime.c:97: for each function it appears in.) microtime.c:103: `RUSAGE_CHILDREN' undeclared (first use in this function) make[3]: *** [microtime.lo] Error 1 make[3]: Leaving directory `/home/master/php-4.0.1/ext/standard' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory `/home/master/php-4.0.1/ext/standard' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/master/php-4.0.1/ext' make: *** [all-recursive] Error 1 </programlisting> </para> <para> Your system is broken. You need to fix your /usr/include files either by making sure your /usr/include/linux symlink is pointing to the right place in your kernel sources or by installing a glibc-devel package that matches your glibc. This has absolutely nothing to do with PHP. To prove this to yourself, try this simple test: <programlisting> $ cat >test.c <<X #include <sys/resource.h> X $ gcc -E test.c >/dev/null </programlisting> If that spews out errors, you know your include files are messed up. </para> </answer> </qandaentry> </qandaset> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: -->