我正在尝试在Mac OS 10.6上编译一个名为xtree的PHP扩展,但是我遇到了一些关于丢失符号的错误。我已经能够在运行Debian 4的机器上成功编译它而没有丢失的符号错误。
makefile显示为:
LIBTOOL = /usr/bin/libtool
INSTALL = /usr/bin/install
PHPINC := $(shell /opt/local/bin/php-config --includes)
PHPLIBS := $(shell /opt/local/bin/php-config --libs)
PHPDEST := $(shell /opt/local/bin/php-config --extension-dir)
XTREE_LIB = xtree2.so
OBJS = xtree.lo tree.lo node.lo parser.lo string.lo token.lo xsock.lo xpath.lo buffer.lo
.SUFFIXES : .lo .c
all : ${XTREE_LIB}
clean :
rm -f *.o
rm -f *.lo
rm -f *.so
.c.lo :
gcc -fpic -DHAVE_XTREE -DPIC -DCOMPILE_DL_XTREE ${PHPINC} -c -o $@ $<
${XTREE_LIB} : ${OBJS}
gcc -shared -L/usr/local/lib -rdynamic -o ${XTREE_LIB} ${OBJS}
install : ${XTREE_LIB}
$(INSTALL) -c ${XTREE_LIB} ${PHPDEST}/${XTREE_LIB}
以下是我在Mac上进行编译时收到的错误示例。
Undefined symbols:
"__php_stream_open_wrapper_ex", referenced from:
_tree_load_xdf in tree.lo
_tree_save_xdf in tree.lo
_tree_cache_control in tree.lo
_get_cache_header in tree.lo
_log_cache_hits in tree.lo
_log_cache_hits in tree.lo
_log_cache_err in tree.lo
_buf_load_file in buffer.lo
_buf_save_file in buffer.lo
"_php_info_print_table_start", referenced from:
_zm_info_xtree in xtree.lo
"_zend_list_insert", referenced from:
_zif_xtree_load in xtree.lo
_zif_xtree_xchg in xtree.lo
_zif_xtree_new in xtree.lo
PHP安装在localhost上正确运行,php-config指向包含,libs,extension-dir等的正确位置。
与我的一些同事交谈,他们建议链接器没有正确地指向库。但是,他不熟悉Mac OS链接器,知道如何解决这个问题。
有什么想法吗?
更新
我也有以下建议,但没有运气:
Anyways, here's a few random things you could try:
- In the linker line of the Makefile (starts with "gcc -shared"), add
the "-dynamiclib" parameter after "gcc". You may also need to remove
the "-shared" and/or "-rdynamic" parameters.
- In the linker line, add "-bundle -flat_namespace -undefined
suppress". Again, you may need to dump "-shared" and/or "-rdynamic".
仍在寻求帮助。谢谢!
答案 0 :(得分:0)
尝试更改:
${XTREE_LIB} : ${OBJS}
gcc -shared -L/usr/local/lib -rdynamic -o ${XTREE_LIB} ${OBJS}
到此:
${XTREE_LIB} : ${OBJS}
gcc -shared -L/usr/local/lib -rdynamic -o ${XTREE_LIB} ${OBJS} $(PHPLIBS)