我試圖在Mac OS 10.6上編譯一個名爲xtree的PHP擴展,但卻遇到了關於丟失符號的幾個錯誤。我已經能夠在運行Debian 4的機器上成功編譯它,而不會丟失符號錯誤。PHP擴展不能在Mac OS上編譯10.6
生成文件顯示爲:
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 [email protected] $<
${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安裝在本地主機和php-配置正確運行指向了包括庫,擴展-dir的正確位置等
談起我的一些同事,他們建議鏈接器不能動態地正確指向庫。但是,他並不熟悉Mac OS鏈接器以瞭解如何解決此問題。
任何想法?
UPDATE
我也有以下建議我,但沒有運氣之一:
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".
仍尋求幫助。謝謝!
做'/選擇/ local/bin目錄/ PHP的配置--libs'與他人合作?另外,我希望'$(PHPLIBS)'可以用在某個地方。 – Wodin 2010-12-20 09:21:58
是的,/ opt/local/bin/php-config --libs和其他工作。 – janiv 2010-12-20 22:42:16