<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Build Problems</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="faq.installation.html">Installation</a></div> <div class="next" style="text-align: right; float: right;"><a href="faq.using.html">Using PHP</a></div> <div class="up"><a href="faq.html">FAQ</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="faq.build" class="chapter"> <h1>Build Problems</h1> <p class="para"> This section gathers most common errors that occur at build time. </p> <div class="qandaset"><ol class="qandaset_questions"><li><a href="#faq.build.configure"> I got the latest version of PHP using the anonymous Git service, but there's no configure script! </a></li><li><a href="#faq.build.configuring"> 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! </a></li><li><a href="#faq.build.lex"> While configuring PHP (./configure), you come across an error similar to the following: checking lex output file root... ./configure: lex: command not found configure: error: cannot find output from lex; giving up </a></li><li><a href="#faq.build.apache-sharedcore"> When I try to start Apache, I get the following message: fatal: relocation error: file /path/to/libphp4.so: symbol ap_block_alarms: referenced symbol not found </a></li><li><a href="#faq.build.not-found"> When I run configure, it says that it can't find the include files or library for GD, gdbm, or some other package! </a></li><li><a href="#faq.build.yytname"> When it is compiling the file language-parser.tab.c, it gives me errors that say yytname undeclared. </a></li><li><a href="#faq.build.link"> 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. </a></li><li><a href="#faq.build.undefined"> When linking PHP, it complains about a number of undefined references. </a></li><li><a href="#faq.build.apache"> I can't figure out how to build PHP with Apache 1.3. </a></li><li><a href="#faq.build.not-running"> 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. </a></li><li><a href="#faq.build.activate-module"> It says to use: --activate-module=src/modules/php4/libphp4.a, but that file doesn't exist, so I changed it to --activate-module=src/modules/php4/libmodphp4.a and it doesn't work!? What's going on? </a></li><li><a href="#faq.build.ansi"> When I try to build Apache with PHP as a static module using --activate-module=src/modules/php4/libphp4.a it tells me that my compiler is not ANSI compliant. </a></li><li><a href="#faq.build.apxs"> When I try to build PHP using --with-apxs I get strange error messages. </a></li><li><a href="#faq.build.microtime"> During make, I get errors in microtime, and a lot of RUSAGE_ stuff. </a></li><li><a href="#faq.build.mysql.tempnam"> When compiling PHP with MySQL, configure runs fine but during make I get an error similar to the following: ext/mysql/ libmysqlclient /my_tempnam.o(.text+0x46): In function my_tempnam': /php4/ext/mysql/ libmysqlclient /my_tempnam.c:103: the use of tempnam' is dangerous, better use mkstemp', what's wrong? </a></li><li><a href="#faq.build.upgrade"> I want to upgrade my PHP. Where can I find the ./configure line that was used to build my current PHP installation? </a></li><li><a href="#faq.build.gdlibs"> When building PHP with the GD library it either gives strange compile errors or segfaults on execution. </a></li><li><a href="#faq.installation.needgnu"> When compiling PHP I seemingly get random errors, like it hangs. I'm using Solaris if that matters. </a></li></ol></div> <dl class="qandaentry" id="faq.build.configure"> <dt><strong> I got the latest version of PHP using the anonymous Git service, but there's no configure script! </strong></dt> <dd class="answer"> <p class="para"> You have to have the GNU autoconf package installed so you can generate the configure script from <var class="filename">configure.in</var>. Just run <strong class="command">./buildconf</strong> in the top-level directory after getting the sources from the Git server. (Also, unless you run <strong class="command">configure</strong> with the <em>--enable-maintainer-mode</em> option, the configure script will not automatically get rebuilt when the <var class="filename">configure.in</var> file is updated, so you should make sure to do that manually when you notice <var class="filename">configure.in</var> has changed. One symptom of this is finding things like @VARIABLE@ in your Makefile after configure or <var class="filename">config.status</var> is run.) </p> </dd> </dl> <dl class="qandaentry" id="faq.build.configuring"> <dt><strong> I'm having problems configuring PHP to work with Apache. It says it can't find <var class="filename">httpd.h</var>, but it's right where I said it is! </strong></dt> <dd class="answer"> <p class="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 <strong class="option configure">--with-apache=/path/to/apache</strong> and <em class="emphasis">not</em> <strong class="option configure">--with-apache=/path/to/apache/src</strong> . </p> </dd> </dl> <dl class="qandaentry" id="faq.build.lex"> <dt><strong> While configuring PHP (<em>./configure</em>), you come across an error similar to the following: <div class="example-contents screen"><br /> checking lex output file root... ./configure: lex: command not found<br /> configure: error: cannot find output from lex; giving up<br /> </div> </strong></dt> <dd class="answer"> <p class="para"> Be sure to read the <a href="install.unix.html" class="link">installation</a> instructions carefully and note that you need both flex and bison installed to compile PHP. Depending on your setup you will install bison and flex from either source or a package, such as a RPM. </p> </dd> </dl> <dl class="qandaentry" id="faq.build.apache-sharedcore"> <dt><strong> When I try to start Apache, I get the following message: <div class="example-contents screen"><br /> fatal: relocation error: file /path/to/libphp4.so:<br /> symbol ap_block_alarms: referenced symbol not found<br /> </div> </strong></dt> <dd class="answer"> <p class="para"> This error usually comes up when one compiles the Apache core program as a DSO library for shared usage. Try to reconfigure apache, making sure to use at least the following flags: </p> <p class="para"> <div class="example-contents screen"><br /> --enable-shared=max --enable-rule=SHARED_CORE<br /> </div> </p> <p class="para"> For more information, read the top-level Apache <var class="filename">INSTALL</var> file or the Apache <a href="http://httpd.apache.org/docs/current/dso.html" class="link external">» DSO manual page</a>. </p> </dd> </dl> <dl class="qandaentry" id="faq.build.not-found"> <dt><strong> When I run configure, it says that it can't find the include files or library for GD, gdbm, or some other package! </strong></dt> <dd class="answer"> <p class="para"> You can make the configure script look for header files and libraries in non-standard locations by specifying additional flags to pass to the C preprocessor and linker, such as: <div class="example-contents"> <div class="cdata"><pre> CPPFLAGS=-I/path/to/include LDFLAGS=-L/path/to/library ./configure </pre></div> </div> If you're using a csh-variant for your login shell (why?), it would be: <div class="example-contents"> <div class="cdata"><pre> env CPPFLAGS=-I/path/to/include LDFLAGS=-L/path/to/library ./configure </pre></div> </div> </p> </dd> </dl> <dl class="qandaentry" id="faq.build.yytname"> <dt><strong> When it is compiling the file <var class="filename">language-parser.tab.c</var>, it gives me errors that say <em>yytname undeclared</em>. </strong></dt> <dd class="answer"> <p class="para"> You need to update your version of Bison. You can find the latest version at <a href="http://www.gnu.org/software/bison/bison.html" class="link external">» http://www.gnu.org/software/bison/bison.html</a>. </p> </dd> </dl> <dl class="qandaentry" id="faq.build.link"> <dt><strong> When I run <strong class="command">make</strong>, it seems to run fine but then fails when it tries to link the final application complaining that it can't find some files. </strong></dt> <dd class="answer"> <p class="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 <strong class="command">cp *.o functions</strong> and then re-running <strong class="command">make</strong> to see if that helps. If it does, you should really upgrade to a recent version of GNU make. </p> </dd> </dl> <dl class="qandaentry" id="faq.build.undefined"> <dt><strong> When linking PHP, it complains about a number of undefined references. </strong></dt> <dd class="answer"> <p class="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. </p> <p class="para"> Some people have also reported that they had to add '-ldl' immediately following <var class="filename">libphp4.a</var> when linking with Apache. </p> </dd> </dl> <dl class="qandaentry" id="faq.build.apache"> <dt><strong> I can't figure out how to build PHP with Apache 1.3. </strong></dt> <dd class="answer"> <p class="para"> This is actually quite easy. Follow these steps carefully: <ul class="itemizedlist"> <li class="listitem"> <span class="simpara"> Grab the latest Apache 1.3 distribution from <a href="http://httpd.apache.org/download.cgi" class="link external">» http://httpd.apache.org/download.cgi</a>. </span> </li> <li class="listitem"> <span class="simpara"> Ungzip and untar it somewhere, for example <var class="filename">/usr/local/src/apache-1.3</var>. </span> </li> <li class="listitem"> <span class="simpara"> Compile PHP by first running <strong class="command">./configure --with-apache=/<path>/apache-1.3</strong> (substitute <path> for the actual path to your apache-1.3 directory). </span> </li> <li class="listitem"> <span class="simpara"> Type <strong class="command">make</strong> followed by <strong class="command">make install</strong> to build PHP and copy the necessary files to the Apache distribution tree. </span> </li> <li class="listitem"> <span class="simpara"> Change directories into to your <var class="filename">/<path>/apache-1.3/src</var> directory and edit the <var class="filename">Configuration</var> file. Add to the file: <em>AddModule modules/php4/libphp4.a</em>. </span> </li> <li class="listitem"> <span class="simpara"> Type: <strong class="command">./configure</strong> followed by <em>make</em>. </span> </li> <li class="listitem"> <span class="simpara"> You should now have a PHP-enabled httpd binary! </span> </li> </ul> </p> <p class="para"> <em class="emphasis">Note:</em> You can also use the new Apache <em>./configure</em> script. See the instructions in the <em>README.configure</em> file which is part of your Apache distribution. Also have a look at the <var class="filename">INSTALL</var> file in the PHP distribution. </p> </dd> </dl> <dl class="qandaentry" id="faq.build.not-running"> <dt><strong> 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. </strong></dt> <dd class="answer"> <p class="para"> This means that the PHP module is not getting invoked for some reason. Three things to check before asking for further help: <ul class="itemizedlist"> <li class="listitem"> <span class="simpara"> Make sure that the httpd binary you are running is the actual new httpd binary you just built. To do this, try running: <em>/path/to/binary/httpd -l</em> </span> <span class="simpara"> If you don't see <var class="filename">mod_php4.c</var> listed then you are not running the right binary. Find and install the correct binary. </span> </li> <li class="listitem"> <span class="simpara"> Make sure you have added the correct Mime Type to one of your <em>Apache .conf</em> files. It should be: <em>AddType application/x-httpd-php .php</em> </span> <span class="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. </span> </li> <li class="listitem"> <span class="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 <var class="filename">httpd.conf</var> file or some other obvious change that will tell you if the file is being read correctly. </span> </li> </ul> </p> </dd> </dl> <dl class="qandaentry" id="faq.build.activate-module"> <dt><strong> It says to use: <em>--activate-module=src/modules/php4/libphp4.a</em>, but that file doesn't exist, so I changed it to <em>--activate-module=src/modules/php4/libmodphp4.a</em> and it doesn't work!? What's going on? </strong></dt> <dd class="answer"> <p class="para"> Note that the <var class="filename">libphp4.a</var> file is not supposed to exist. The apache process will create it! </p> </dd> </dl> <dl class="qandaentry" id="faq.build.ansi"> <dt><strong> When I try to build Apache with PHP as a static module using <em>--activate-module=src/modules/php4/libphp4.a</em> it tells me that my compiler is not ANSI compliant. </strong></dt> <dd class="answer"> <p class="para"> This is a misleading error message from Apache that has been fixed in more recent versions. </p> </dd> </dl> <dl class="qandaentry" id="faq.build.apxs"> <dt><strong> When I try to build PHP using <strong class="option configure">--with-apxs</strong> I get strange error messages. </strong></dt> <dd class="answer"> <p class="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. Find your apxs script (try the command <strong class="command">which apxs</strong>), it's sometimes found in <var class="filename">/usr/local/apache/bin/apxs</var> or <var class="filename">/usr/sbin/apxs</var>. Open it and check for lines similar to these: <div class="example-contents"> <div class="cdata"><pre> my $CFG_CFLAGS_SHLIB = ' '; # substituted via Makefile.tmpl my $CFG_LD_SHLIB = ' '; # substituted via Makefile.tmpl my $CFG_LDFLAGS_SHLIB = ' '; # substituted via Makefile.tmpl </pre></div> </div> If this is what you see, you have found your problem. They may contain just spaces or other incorrect values, such as 'q()'. Change these lines to say: <div class="example-contents"> <div class="cdata"><pre> 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 </pre></div> </div> The second possible problem should only be an issue on Red Hat 6.1 and 6.2. The apxs script Red Hat ships is broken. Look for this line: <div class="example-contents"> <div class="cdata"><pre> my $CFG_LIBEXECDIR = 'modules'; # substituted via APACI install </pre></div> </div> If you see the above line, change it to this: <div class="example-contents"> <div class="cdata"><pre> my $CFG_LIBEXECDIR = '/usr/lib/apache'; # substituted via APACI install </pre></div> </div> Last, if you reconfigure/reinstall Apache, add a <strong class="command">make clean</strong> to the process after <strong class="command">./configure</strong> and before <strong class="command">make</strong>. </p> </dd> </dl> <dl class="qandaentry" id="faq.build.microtime"> <dt><strong> During <strong class="command">make</strong>, I get errors in microtime, and a lot of <em>RUSAGE_</em> stuff. </strong></dt> <dd class="answer"> <p class="para"> During the <strong class="command">make</strong> portion of installation, if you encounter problems that look similar to this: <div class="example-contents"> <div class="cdata"><pre> 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 </pre></div> </div> </p> <p class="para"> Your system is broken. You need to fix your <var class="filename">/usr/include</var> files 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: <div class="example-contents"> <div class="cdata"><pre> $ cat >test.c <<X #include <sys/resource.h> X $ gcc -E test.c >/dev/null </pre></div> </div> If that spews out errors, you know your include files are messed up. </p> </dd> </dl> <dl class="qandaentry" id="faq.build.mysql.tempnam"> <dt><strong> When compiling PHP with MySQL, configure runs fine but during <em>make</em> I get an error similar to the following: <em class="emphasis">ext/mysql/ libmysqlclient /my_tempnam.o(.text+0x46): In function my_tempnam': /php4/ext/mysql/ libmysqlclient /my_tempnam.c:103: the use of tempnam' is dangerous, better use mkstemp'</em>, what's wrong? </strong></dt> <dd class="answer"> <p class="para"> First, it's important to realize that this is a <em> Warning</em> and not a fatal error. Because this is often the last output seen during <em>make</em>, it may seem like a fatal error but it's not. Of course, if you set your compiler to die on Warnings, it will. Also keep in mind that MySQL support is enabled by default. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> As of PHP 4.3.2, you'll also see the following text after the build (make) completes: </p> <p class="para"> <div class="example-contents screen"><br /> Build complete.<br /> (It is safe to ignore warnings about tempnam and tmpnam).<br /> </div> </p> </p></blockquote> </dd> </dl> <dl class="qandaentry" id="faq.build.upgrade"> <dt><strong> I want to upgrade my PHP. Where can I find the <strong class="command">./configure</strong> line that was used to build my current PHP installation? </strong></dt> <dd class="answer"> <p class="para"> Either you look at config.nice file, in the source tree of your current PHP installation or, if this is not available, you simply run a <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php phpinfo</span><span style="color: #007700">(); </span><span style="color: #0000BB">?></span> </span> </code></div> </div> script. On top of the output the <strong class="command">./configure</strong> line, that was used to build this PHP installation is shown. </p> </dd> </dl> <dl class="qandaentry" id="faq.build.gdlibs"> <dt><strong> When building PHP with the GD library it either gives strange compile errors or segfaults on execution. </strong></dt> <dd class="answer"> <p class="para"> Make sure your GD library and PHP are linked against the same depending libraries (e.g. libpng). </p> </dd> </dl> <dl class="qandaentry" id="faq.installation.needgnu"> <dt><strong> When compiling PHP I seemingly get random errors, like it hangs. I'm using Solaris if that matters. </strong></dt> <dd class="answer"> <p class="para"> Using non-GNU utilities while compiling PHP may cause problems. Be sure to use GNU tools in order to be certain that compiling PHP will work. For example, on Solaris, using either the SunOS BSD-compatible or Solaris versions of <em>sed</em> will not work, but using the GNU or Sun POSIX (xpg4) versions of <em>sed</em> will work. Links: <a href="http://www.gnu.org/software/sed/sed.html" class="link external">» GNU sed</a>, <a href="http://www.gnu.org/software/flex/flex.html" class="link external">» GNU flex</a>, and <a href="http://www.gnu.org/software/bison/bison.html" class="link external">» GNU bison</a>. </p> </dd> </dl> </div> <hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="faq.installation.html">Installation</a></div> <div class="next" style="text-align: right; float: right;"><a href="faq.using.html">Using PHP</a></div> <div class="up"><a href="faq.html">FAQ</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>