Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Compiling apiextractor on Mac OS X failed (lib not found libxml2)

    Language Bindings
    2
    5
    5762
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • U
      uranusjr last edited by

      Hi,

      I've been trying to compile PySide on my Mac OS X 10.7 Lion machine, but got stuck right away when I tried to compile apiextractor.

      The cmake process ended fine, except that it says it couldn't find libxslt and sphinx-build, so doc target is disabled. But then this happened:

      Linking CXX shared library tests/libapiextractor.dylib
      ld: framework not found libxml2
      collect2: ld returned 1 exit status
      make[2]: *** [tests/libapiextractor.0.10.6.dylib] Error 1
      make[1]: *** [CMakeFiles/apiextractor.dir/all] Error 2
      make: *** [all] Error 2

      After some searching I found that Mac OS X does have libxml2 as a framework, which is at /Library/Frameworks/libxml2.framework. But after make VERBOSE=1 I found that the linking command does have the right search path specified:

      /usr/bin/c++ -F/Library/Frameworks -Wall -fvisibility=hidden -dynamiclib -Wl,-headerpad_max_install_names -compatibility_version 0.10.0 -current_version 0.10.6 -o [blah blah blah] -F/usr/local/Cellar/qt/4.7.4/lib /usr/lib/libxslt.dylib -framework libxml2 -framework QtCore -framework QtXmlPatterns -framework QtXml

      (I'm trying to build PySide against Qt from Homebrew, thus the -F/usr/local/Cellar path. But that doesn't seem to be the problem.)

      As above, there is a -F/Library/Frameworks in the flags, but the linker still couldn't find libxml2. I am not really familiar with cmake, and am really in a lost now.

      Thanks for the help in advance.

      1 Reply Last reply Reply Quote 0
      • G
        goetz last edited by

        On a standard OS X installation (checked against 10.6/Snow Leo and 10.7/Lion), there is no libxml2 framework, but only a regular shared library in /usr/lib/libxml2.dylib. You should try to link against that lib, not a framework by using "-lxml2" instead of "-framework libxml2".

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply Reply Quote 0
        • U
          uranusjr last edited by

          Thanks for the info. I've read some articles on the Internet that said the same, but since my machine does have /Library/Frameworks/libxml2.framework (see below), I thought this was added in Lion. Seems like I was wrong, maybe it came from some other package I installed.

          I edited CMakeLists.txt and changed
          set(APIEXTRACTOR_EXTRA_LIBRARIES ${LIBXSLT_LIBRARIES} ${LIBXML2_LIBRARIES})
          to
          set(APIEXTRACTOR_EXTRA_LIBRARIES ${LIBXSLT_LIBRARIES} "-lxml2")
          and the building succeeded. thanks!

          Another question: I'm not familiar with cmake, is there a "better" way of doing this, like specifying some flags in the cmake command? Manually editing CMakeLists.txt doesn't seem very standard, and would be hard to document if I wish to explain this build flow to someone else.

          Thanks.

          Below is a snip of the output of cmake:

          -- Found Qt4: /usr/local/bin/qmake (found suitable version "4.7.4", required is "4.5.0")
          -- Found LibXml2: /Library/Frameworks/libxml2.framework (Required is at least version "2.6.32")
          -- checking for module 'libxslt'
          -- package 'libxslt' not found
          -- Found LibXslt: /usr/lib/libxslt.dylib (Required is at least version "1.1.19")
          -- sphinx-build - not found! doc target disabled

          Seems that LibXml2 is found by cmake, but the path is not recognized by the linker? Don't understand...

          1 Reply Last reply Reply Quote 0
          • G
            goetz last edited by

            Sorry, I'm not familiar with CMake, so I'm of no help here. You might want to ask in one of the CMake users help channels.

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply Reply Quote 0
            • U
              uranusjr last edited by

              OK, will do, thanks.

              By the way, after some probing I found my libxml2.framework under /Library/Frameworks seems to be corrupted for some reason. This explains why the linker can't link it even though cmake "recognizes" the framework.

              Thanks for all the info.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post