Saturday, February 12, 2011

php build - undefined reference to php_glob_stream may be resolved with make distclean

Problem Description:

While building php-5.3x for use with apache  http server, we followed a successful

# ./configure --enable-option ...

with

# make

But the make failed.  After deploying what we thought should fix the make problem we reran configure  successfully again; but make failed with a different error output.  Here is the tail end error output (yours may be similar if not same):

..............................sevelra lines omitted.........
/Stage/php-5.3.5/ext/spl/spl_directory.c:168: undefined reference to `php_glob_stream                                          _ops'
/Stage/php-5.3.5/ext/spl/spl_directory.c:169: undefined reference to `_php_glob_strea                                          m_get_path'
ext/spl/.libs/spl_directory.o: In function `spl_filesystem_object_get_debug_info':
/Stage/php-5.3.5/ext/spl/spl_directory.c:579: undefined reference to `php_glob_stream                                          _ops'
ext/spl/.libs/spl_directory.o: In function `zim_spl_GlobIterator_count':
/Stage/php-5.3.5/ext/spl/spl_directory.c:1460: undefined reference to `php_glob_strea                                          m_ops'
/Stage/php-5.3.5/ext/spl/spl_directory.c:1461: undefined reference to `_php_glob_stre                                          am_get_count'
ext/standard/.libs/basic_functions.o: In function `zm_startup_basic':
/Stage/php-5.3.5/ext/standard/basic_functions.c:3651: undefined reference to `php_glo                                          b_stream_wrapper'
ext/zip/.libs/php_zip.o: In function `php_zip_add_from_pattern':
/Stage/php-5.3.5/ext/zip/php_zip.c:1632: undefined reference to `php_zip_glob'
/Stage/php-5.3.5/ext/zip/php_zip.c:1634: undefined reference to `php_zip_pcre'
main/streams/.libs/plain_wrapper.o: In function `php_plain_files_dir_opener':
/Stage/php-5.3.5/main/streams/plain_wrapper.c:857: undefined reference to `php_glob_s                                          tream_wrapper'
/Stage/php-5.3.5/main/streams/plain_wrapper.c:857: undefined reference to `php_glob_s                                          tream_wrapper'
collect2: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1

How we fixed the Problem:
To fix the problem try
# make clean

Then run
#make distclean

Actually 'make clean' is a subset of 'make distclean'.  So just running 'make distclean' should be
enough.  After the make distclean, we reran 'configure' and then 'make'  and all was well again.  Apparently the 'make distclean' ensured we got rid of all previous build objects so that a new build with our fixes and adjustments contained only objects that are consistent with each other.

The takeaway is this: If you have previously ran 'make' or 'make install' then always run 'make distclean' if you make any changes such as library, include header, '--with-package', '--enable-package', etc., changes before you rebuild from the 'configure' step.  Hope this helps.

No comments:

Post a Comment

Internet blogs