I found one problem. I had to add "=shared" after --enable-my_ext. So, this is what I did:
./configure --enable-my_ext=shared
Now, the makefile looks much better. (I have attached the Makefile.) However, I get errors in make. Those errors are generated when invoking the libtool command.
[EMAIL PROTECTED] tryExtendPHP4.3.3]$ make
/bin/sh /home/anas/shop/tryExtendPHP4.3.3/libtool --mode=compile gcc -I. -I/home/anas/shop/tryExtendPHP4.3.3 -DPHP_ATOM_INC -I/home/anas/shop/tryExtendPHP4.3.3/include -I/home/anas/shop/tryExtendPHP4.3.3/main -I/home/anas/shop/tryExtendPHP4.3.3 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/Zend -I/usr/local/include/php/TSRM -DHAVE_CONFIG_H -g -O2 -prefer-pic -c /home/anas/shop/tryExtendPHP4.3.3/my_ext.c -o my_ext.lo
/home/anas/shop/tryExtendPHP4.3.3/libtool: s%^.*/%%: No such file or directory
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
: compile: cannot determine name of library object from `'
make: *** [my_ext.lo] Error 1
I don't know what is going on. Could some expert please advise. Thank you.
Here is output of the same command with --debug option:
[EMAIL PROTECTED] tryExtendPHP4.3.3]$ make
/bin/sh /home/anas/shop/tryExtendPHP4.3.3/libtool --debug --mode=compile gcc -I. -I/home/anas/shop/tryExtendPHP4.3.3 -DPHP_ATOM_INC -I/home/anas/shop/tryExtendPHP4.3.3/include -I/home/anas/shop/tryExtendPHP4.3.3/main -I/home/anas/shop/tryExtendPHP4.3.3 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/Zend -I/usr/local/include/php/TSRM -DHAVE_CONFIG_H -g -O2 -prefer-pic -c /home/anas/shop/tryExtendPHP4.3.3/my_ext.c -o my_ext.lo
/home/anas/shop/tryExtendPHP4.3.3/libtool: s%^.*/%%: No such file or directory
: enabling shell trace mode
+ test 20 -gt 0
+ arg=--mode=compile
+ shift
++ echo X--mode=compile
++ -e '1s/^X//' -e 's/[-_a-zA-Z0-9]*=//'
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
+ optarg=
+ test -n ''
+ mode=
+ test 19 -gt 0
+ arg=gcc
+ shift
+ optarg=
+ test -n ''
+ nonopt=gcc
+ break
+ test -n ''
+ exec_cmd=
+ test -z ''
+ test -z ''
+ mode=link
+ mode=compile
+ break
+ test -n ''
+ generic_help=Try ` --help' for more information.
+ help=Try ` --help --mode=compile' for more information.
+ modename=: compile
+ base_compile=
+ prev=
+ lastarg=
+ srcfile=gcc
+ suppress_output=
+ user_target=no
+ lastarg=gcc
+ srcfile=-I.
++ echo Xgcc
++ -e '1s/^X//' -e 's/\([\\`\\"$\\\\]\)/\\\1/g'
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
+ lastarg=
+ lastarg=""
+ test -z ''
+ base_compile=""
+ lastarg=-I.
+ srcfile=-I/home/anas/shop/tryExtendPHP4.3.3
++ echo X-I.
++ -e '1s/^X//' -e 's/\([\\`\\"$\\\\]\)/\\\1/g'
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
+ lastarg=
+ lastarg=""
+ test -z '""'
+ base_compile="" ""
+ lastarg=-I/home/anas/shop/tryExtendPHP4.3.3
+ srcfile=-DPHP_ATOM_INC
++ echo X-I/home/anas/shop/tryExtendPHP4.3.3
++ -e '1s/^X//' -e 's/\([\\`\\"$\\\\]\)/\\\1/g'
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
+ lastarg=
+ lastarg=""
+ test -z '"" ""'
+ base_compile="" "" ""
+ lastarg=-DPHP_ATOM_INC
+ srcfile=-I/home/anas/shop/tryExtendPHP4.3.3/include
++ echo X-DPHP_ATOM_INC
++ -e '1s/^X//' -e 's/\([\\`\\"$\\\\]\)/\\\1/g'
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
+ lastarg=
+ lastarg=""
+ test -z '"" "" ""'
+ base_compile="" "" "" ""
+ lastarg=-I/home/anas/shop/tryExtendPHP4.3.3/include
+ srcfile=-I/home/anas/shop/tryExtendPHP4.3.3/main
++ echo X-I/home/anas/shop/tryExtendPHP4.3.3/include
++ -e '1s/^X//' -e 's/\([\\`\\"$\\\\]\)/\\\1/g'
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
+ lastarg=
+ lastarg=""
+ test -z '"" "" "" ""'
+ base_compile="" "" "" "" ""
+ lastarg=-I/home/anas/shop/tryExtendPHP4.3.3/main
+ srcfile=-I/home/anas/shop/tryExtendPHP4.3.3
++ echo X-I/home/anas/shop/tryExtendPHP4.3.3/main
++ -e '1s/^X//' -e 's/\([\\`\\"$\\\\]\)/\\\1/g'
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
+ lastarg=
+ lastarg=""
+ test -z '"" "" "" "" ""'
+ base_compile="" "" "" "" "" ""
+ lastarg=-I/home/anas/shop/tryExtendPHP4.3.3
+ srcfile=-I/usr/local/include/php
++ echo X-I/home/anas/shop/tryExtendPHP4.3.3
++ -e '1s/^X//' -e 's/\([\\`\\"$\\\\]\)/\\\1/g'
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
+ lastarg=
+ lastarg=""
+ test -z '"" "" "" "" "" ""'
+ base_compile="" "" "" "" "" "" ""
+ lastarg=-I/usr/local/include/php
+ srcfile=-I/usr/local/include/php/main
++ echo X-I/usr/local/include/php
++ -e '1s/^X//' -e 's/\([\\`\\"$\\\\]\)/\\\1/g'
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
+ lastarg=
+ lastarg=""
+ test -z '"" "" "" "" "" "" ""'
+ base_compile="" "" "" "" "" "" "" ""
+ lastarg=-I/usr/local/include/php/main
+ srcfile=-I/usr/local/include/php/Zend
++ echo X-I/usr/local/include/php/main
++ -e '1s/^X//' -e 's/\([\\`\\"$\\\\]\)/\\\1/g'
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
+ lastarg=
+ lastarg=""
+ test -z '"" "" "" "" "" "" "" ""'
+ base_compile="" "" "" "" "" "" "" "" ""
+ lastarg=-I/usr/local/include/php/Zend
+ srcfile=-I/usr/local/include/php/TSRM
++ echo X-I/usr/local/include/php/Zend
++ -e '1s/^X//' -e 's/\([\\`\\"$\\\\]\)/\\\1/g'
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
+ lastarg=
+ lastarg=""
+ test -z '"" "" "" "" "" "" "" "" ""'
+ base_compile="" "" "" "" "" "" "" "" "" ""
+ lastarg=-I/usr/local/include/php/TSRM
+ srcfile=-DHAVE_CONFIG_H
++ echo X-I/usr/local/include/php/TSRM
++ -e '1s/^X//' -e 's/\([\\`\\"$\\\\]\)/\\\1/g'
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
+ lastarg=
+ lastarg=""
+ test -z '"" "" "" "" "" "" "" "" "" ""'
+ base_compile="" "" "" "" "" "" "" "" "" "" ""
+ lastarg=-DHAVE_CONFIG_H
+ srcfile=-g
++ echo X-DHAVE_CONFIG_H
++ -e '1s/^X//' -e 's/\([\\`\\"$\\\\]\)/\\\1/g'
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
+ lastarg=
+ lastarg=""
+ test -z '"" "" "" "" "" "" "" "" "" "" ""'
+ base_compile="" "" "" "" "" "" "" "" "" "" "" ""
+ lastarg=-g
+ srcfile=-O2
++ echo X-g
++ -e '1s/^X//' -e 's/\([\\`\\"$\\\\]\)/\\\1/g'
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
+ lastarg=
+ lastarg=""
+ test -z '"" "" "" "" "" "" "" "" "" "" "" ""'
+ base_compile="" "" "" "" "" "" "" "" "" "" "" "" ""
+ pic_mode=yes
+ continue
+ lastarg=-O2
+ srcfile=-c
++ echo X-O2
++ -e '1s/^X//' -e 's/\([\\`\\"$\\\\]\)/\\\1/g'
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
+ lastarg=
+ lastarg=""
+ test -z '"" "" "" "" "" "" "" "" "" "" "" "" ""'
+ base_compile="" "" "" "" "" "" "" "" "" "" "" "" "" ""
+ lastarg=-c
+ srcfile=/home/anas/shop/tryExtendPHP4.3.3/my_ext.c
++ echo X-c
++ -e '1s/^X//' -e 's/\([\\`\\"$\\\\]\)/\\\1/g'
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
+ lastarg=
+ lastarg=""
+ test -z '"" "" "" "" "" "" "" "" "" "" "" "" "" ""'
+ base_compile="" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
+ test no '!=' no
+ user_target=next
+ user_target=yes
+ continue
+ user_target=set
+ libobj=my_ext.lo
+ continue
+ xform=[cCFSfmso]
++ echo Xmy_ext.lo
++ -e '1s/^X//' -e 's/\.[cCFSfmso]$/.lo/'
/home/anas/shop/tryExtendPHP4.3.3/libtool: -e: command not found
+ libobj=
+ echo ': compile: cannot determine name of library object from `'\'''
: compile: cannot determine name of library object from `'
+ exit 1
make: *** [my_ext.lo] Error 1
Curt Zirzow wrote:
* Thus wrote Anas Mughal ([EMAIL PROTECTED]):
I have followed the instructions in the PHP documentation on how to build a custom dynamic extension. After running ext_skel, I did NOT add any custom methods. I built the extension using the followind commands:
Compiling cc -fpic -DCOMPILE_DL=1 -I/usr/local/include -I. -I.. -I../Zend -c -o <your_object_file> <your_c_file>
Linking cc -shared -L/usr/local/lib -rdynamic -o <your_module_file> <your_object_file(s)>
1. edit the config.m4 and remove the dnl's on the lines that look somethign like: dnl PHP_ARG_ENABLE(baz, whether to enable baz support, dnl Make sure that the comment is aligned: dnl [ --enable-baz Enable baz support])
2. ./phpize
Creates the configure environment
3. ./configure --enable-baz 4. make 5. make install
the make install just copies the file in the modules/ dir to your php module directory.
HTH,
Curt
srcdir = /home/anas/shop/tryExtendPHP4.3.3 builddir = /home/anas/shop/tryExtendPHP4.3.3 top_srcdir = /home/anas/shop/tryExtendPHP4.3.3 top_builddir = /home/anas/shop/tryExtendPHP4.3.3 SHLIB_SUFFIX_NAME = so shared_objects_my_ext = my_ext.lo PHP_MODULES = $(phplibdir)/my_ext.la all_targets = $(PHP_MODULES) install_targets = install-modules prefix = /usr/local exec_prefix = $(prefix) libdir = ${exec_prefix}/lib prefix = /usr/local phplibdir = /home/anas/shop/tryExtendPHP4.3.3/modules PHP_COMPILE = CC = gcc CFLAGS = -g -O2 CFLAGS_CLEAN = -g -O2 CPP = gcc -E CPPFLAGS = -DHAVE_CONFIG_H CXX = DEFS = EXTENSION_DIR = /usr/local/lib/php/extensions/no-debug-non-zts-20020429 EXTRA_LDFLAGS = EXTRA_LIBS = INCLUDES = -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/Zend -I/usr/local/include/php/TSRM LEX = LEX_OUTPUT_ROOT = LFLAGS = LDFLAGS = SHARED_LIBTOOL = LIBTOOL = $(SHELL) $(top_builddir)/libtool SHELL = /bin/sh AWK = gawk mkinstalldirs = $(top_srcdir)/build/shtool mkdir -p INSTALL = $(top_srcdir)/build/shtool install -c INSTALL_DATA = $(INSTALL) -m 644
DEFS = -DPHP_ATOM_INC -I$(top_builddir)/include -I$(top_builddir)/main -I$(top_srcdir) COMMON_FLAGS = $(DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CPPFLAGS) $(PHP_FRAMEWORKPATH) all: $(all_targets) @echo @echo "Build complete." @echo "(It is safe to ignore warnings about tempnam and tmpnam)." @echo build-modules: $(PHP_MODULES) libphp4.la: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -rpath $(phptempdir) $(EXTRA_LDFLAGS) $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ [EMAIL PROTECTED](LIBTOOL) --silent --mode=install cp libphp4.la $(phptempdir)/libphp4.la >/dev/null 2>&1 libs/libphp4.bundle: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(CC) $(MH_BUNDLE_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_SAPI_OBJS:.lo=.o) $(PHP_FRAMEWORKS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ && cp $@ libs/libphp4.so install: $(all_targets) $(install_targets) install-sapi: $(OVERALL_TARGET) @echo "Installing PHP SAPI module: $(PHP_SAPI)" [EMAIL PROTECTED](mkinstalldirs) $(INSTALL_ROOT)$(bindir) [EMAIL PROTECTED] test ! -r $(phptempdir)/libphp4.$(SHLIB_SUFFIX_NAME); then \ for i in 0.0.0 0.0 0; do \ if test -r $(phptempdir)/libphp4.$(SHLIB_SUFFIX_NAME).$$i; then \ $(LN_S) $(phptempdir)/libphp4.$(SHLIB_SUFFIX_NAME).$$i $(phptempdir)/libphp4.$(SHLIB_SUFFIX_NAME); \ break; \ fi; \ done; \ fi @$(INSTALL_IT) install-modules: build-modules @test -d modules && \ $(mkinstalldirs) $(INSTALL_ROOT)$(EXTENSION_DIR) && \ echo "Installing shared extensions: $(INSTALL_ROOT)$(EXTENSION_DIR)/" && \ rm -f modules/*.la && \ $(INSTALL) modules/* $(INSTALL_ROOT)$(EXTENSION_DIR) >/dev/null 2>&1 || true install-tester: @echo "Installing regression tester: $(INSTALL_ROOT)$(PEAR_INSTALLDIR)/" @$(mkinstalldirs) $(INSTALL_ROOT)$(PEAR_INSTALLDIR) @$(INSTALL) -m 755 $(top_srcdir)/run-tests.php $(INSTALL_ROOT)$(PEAR_INSTALLDIR) install-su: install-pear install-tester test: [EMAIL PROTECTED] test -x $(SAPI_CLI_PATH) && test ! -z $(SAPI_CLI_PATH); then \ TEST_PHP_EXECUTABLE=$(top_builddir)/$(SAPI_CLI_PATH) \ TEST_PHP_SRCDIR=$(top_srcdir) \ CC="$(CC)" \ $(top_builddir)/$(SAPI_CLI_PATH) -d 'open_basedir=' -d 'safe_mode=0' -d 'output_buffering=0' $(top_srcdir)/run-tests.php $(TESTS); \ else \ echo "ERROR: Cannot run tests without CLI sapi."; \ fi clean: find . -name \*.lo | xargs rm -f find . -name \*.o | xargs rm -f find . -name \*.la | xargs rm -f find . -name \*.a | xargs rm -f find . -name \*.so | xargs rm -f find . -name .libs -a -type d|xargs rm -rf rm -f libphp4.la $(SAPI_CLI_PATH) $(OVERALL_TARGET) modules/* libs/* distclean: clean rm -f config.cache config.log config.status Makefile.objects Makefile.fragments libtool main/php_config.h stamp-h php4.spec sapi/apache/libphp4.module buildmk.stamp egrep define'.*include/php' configure|sed 's/.*>//'|xargs rm -f find . -name Makefile | xargs rm -f .PHONY: all clean install distclean test .NOEXPORT: my_ext.lo: /home/anas/shop/tryExtendPHP4.3.3/my_ext.c $(LIBTOOL) --debug --mode=compile $(CC) -I. -I/home/anas/shop/tryExtendPHP4.3.3 $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -prefer-pic -c /home/anas/shop/tryExtendPHP4.3.3/my_ext.c -o my_ext.lo $(phplibdir)/my_ext.la: ./my_ext.la $(LIBTOOL) --mode=install cp ./my_ext.la $(phplibdir) ./my_ext.la: $(shared_objects_my_ext) $(MY_EXT_SHARED_DEPENDENCIES) $(LIBTOOL) --mode=link $(CC) $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) -o $@ -export-dynamic -avoid-version -prefer-pic -module -rpath $(phplibdir) $(EXTRA_LDFLAGS) $(shared_objects_my_ext) $(MY_EXT_SHARED_LIBADD)
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php