September 12, 2011

uranusjr uranusjr
Lab Rat
77 posts

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

 

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
make2: *** [tests/libapiextractor.0.10.6.dylib] Error 1
make1: *** [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.

4 replies

September 13, 2011

Volker Volker
Robot Herder
5428 posts

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”.

September 13, 2011

uranusjr uranusjr
Lab Rat
77 posts

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…

September 13, 2011

Volker Volker
Robot Herder
5428 posts

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.

September 13, 2011

uranusjr uranusjr
Lab Rat
77 posts

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.

 
  ‹‹ [Moved] How to rotate QPushButton?      QListWidget Drag & Drop External File Drop and Internal Reordering ››

You must log in to post a reply. Not a member yet? Register here!