如何在mac os x上编译库以使其支持平面命名空间?

时间:2012-11-15 14:29:49

标签: macos shared-libraries libxml2 universal-binary

我的libxml2有问题。当我尝试update_dyld_shared_cache时,它会说:

update_dyld_shared_cache failed: flat namespace not supported in /usr/lib/libxml2.2.dylib

我用这种方式编译了libxml2:

./configure --prefix=/usr --disable-dependency-tracking
make CFLAGS='-arch i386 -arch x86_64 -arch ppc -arch ppc64' LDFLAGS='-flat_namespace'

我哪里错了?

更新

Liking似乎实际上使用了flat-nampespace标志:

/bin/sh ./libtool --tag=CC   --mode=link gcc  -arch i386 -arch x86_64 -arch ppc -arch ppc64 -version-info 9:2:7  -flat_namespace -o libxml2.la -rpath /usr/lib SAX.lo entities.lo encoding.lo error.lo parserInternals.lo parser.lo tree.lo hash.lo list.lo xmlIO.lo xmlmemory.lo uri.lo valid.lo xlink.lo HTMLparser.lo HTMLtree.lo debugXML.lo xpath.lo xpointer.lo xinclude.lo nanohttp.lo nanoftp.lo DOCBparser.lo catalog.lo globals.lo threads.lo c14n.lo xmlstring.lo xmlregexp.lo xmlschemas.lo xmlschemastypes.lo xmlunicode.lo xmlreader.lo relaxng.lo dict.lo SAX2.lo xmlwriter.lo legacy.lo chvalid.lo pattern.lo xmlsave.lo xmlmodule.lo schematron.lo -lpthread -lz -liconv -lm  
gcc -dynamiclib ${wl}-flat_namespace ${wl}-undefined ${wl}suppress -o .libs/libxml2.2.dylib  .libs/SAX.o .libs/entities.o .libs/encoding.o .libs/error.o .libs/parserInternals.o .libs/parser.o .libs/tree.o .libs/hash.o .libs/list.o .libs/xmlIO.o .libs/xmlmemory.o .libs/uri.o .libs/valid.o .libs/xlink.o .libs/HTMLparser.o .libs/HTMLtree.o .libs/debugXML.o .libs/xpath.o .libs/xpointer.o .libs/xinclude.o .libs/nanohttp.o .libs/nanoftp.o .libs/DOCBparser.o .libs/catalog.o .libs/globals.o .libs/threads.o .libs/c14n.o .libs/xmlstring.o .libs/xmlregexp.o .libs/xmlschemas.o .libs/xmlschemastypes.o .libs/xmlunicode.o .libs/xmlreader.o .libs/relaxng.o .libs/dict.o .libs/SAX2.o .libs/xmlwriter.o .libs/legacy.o .libs/chvalid.o .libs/pattern.o .libs/xmlsave.o .libs/xmlmodule.o .libs/schematron.o  -lpthread -lz /usr/lib/libiconv.dylib -lm  -arch i386 -arch x86_64 -arch ppc -arch ppc64 -install_name  /usr/lib/libxml2.2.dylib -compatibility_version 10 -current_version 10.2
(cd .libs && rm -f libxml2.dylib && ln -s libxml2.2.dylib libxml2.dylib)
(cd .libs && rm -f libxml2.2.7.2.dylib && ln -s libxml2.2.dylib libxml2.2.7.2.dylib)
ar cru .libs/libxml2.a  SAX.o entities.o encoding.o error.o parserInternals.o parser.o tree.o hash.o list.o xmlIO.o xmlmemory.o uri.o valid.o xlink.o HTMLparser.o HTMLtree.o debugXML.o xpath.o xpointer.o xinclude.o nanohttp.o nanoftp.o DOCBparser.o catalog.o globals.o threads.o c14n.o xmlstring.o xmlregexp.o xmlschemas.o xmlschemastypes.o xmlunicode.o xmlreader.o relaxng.o dict.o SAX2.o xmlwriter.o legacy.o chvalid.o pattern.o xmlsave.o xmlmodule.o schematron.o
ranlib .libs/libxml2.a

更新

otools显示:

$ otool -hV /usr/lib/libxml2.2.dylib 
/usr/lib/libxml2.2.dylib:
Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
   MH_MAGIC    I386        ALL  0x00       DYLIB    12       1348 DYLDLINK NO_REEXPORTED_DYLIBS

$ otool -L /usr/lib/libxml2.2.dylib 
/usr/lib/libxml2.2.dylib:
    /usr/lib/libxml2.2.dylib (compatibility version 10.0.0, current version 10.2.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.1.7)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
    /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
    /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)

更新

我尝试使用lipo创建通用库,但似乎它已经破坏了某些东西。将通用库复制到/usr/lib后,update_dyld_shared_cache说了这个:

update_dyld_shared_cache failed: in /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation can't find dylib /usr/lib/libxml2.2.dylib

0 个答案:

没有答案