libxml/tree.h no such file or directory

后端 未结 22 2862
刺人心
刺人心 2020-11-27 10:47

I am getting following errors.

libxml/tree.h no such file or directory

I have already added libxml2.dylib to my pro

相关标签:
22条回答
  • 2020-11-27 11:05

    @Aqib Mumtaz - I got it working by following the instructions in Parris' note above entitled "Adding libxml2 in Xcode 4.3 / 5 / 6". The step in using a Framework Search Path does not work and the compiler complains. Big kudos to that fella anyway!

    I am using Xcode 6.2b3

    Regardless of the version of Xcode you are using, it is buggy. Don't always assume that compile errors are real. There are many times when it does not follow header search paths and includes clearly listed are not found. Worse, the errors that result tend to point you in different directions so you waste a lot of time dinking around with distractions. With that said...

    Recommend baby steps by starting with this exactly...:

    1. create a single window Mac OS X Cocoa project called "Bench Test"
    2. add XpathQuery into your project source directory directly in the Finder
    3. click on the tiny folder icon under the project window's red close button
    4. drag XpathQuery (folder if you contained it) into the project assets on the left of the project window's display
    5. drag /Applications/Xcode/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/lib/libxml2.2.dylib into your project assets, at the bottom. This will add it into your "Build Phases" -> "Link Binary With Libraries" the easy way
    6. click on the "Bench Test" project icon in the project assets column, top of the left
    7. search for "Other Linker Flags" under "Build Settings"
    8. add "-lxml2" (sans "") to "Other Linker Flags" under the "Bench Test" project icon column
    9. search for "header search" under "Build Settings"
    10. add "$(SDKROOT)/usr/include/libxml2" (sans "") to "Header Search Paths" under the "Bench Test" project icon column
    11. add "$(SDKROOT)/usr/include/libxml2" (sans "") to "User Header Search Paths" under the "Bench Test" project icon column

    Notes:

    • Mine would not work until I added that search path to both "Header Search Paths" and "User Header Search Paths".
    • To get to the libxml2.2.dylib in the finder, you will need to right click your Xcode icon and select "Show Package Contacts" (editorial: what a hack.. cramming all that garbage into the app)
    • Be prepared to change the linked libxml2.2.dylib. The one inside Xcode is intentionally used to ensure that Xcode gets something it knows about and in theory was tested. You may want to use the dylib in the system later (read up in this thread)
    • As I am using Xcode 6.2b3, I may have a newer libxml2.2.dylib. Yours could be named slightly different. Just search the folder for something that starts with "libxml" and ends with ".dylib" and that should be it. There may also be an alias like "libxml2.dylib". Don't use that right away as resolving an alias adds another variable into the Xcode "what could have bugs" equation.
    • For sanity sake, I make aliases of the external libraries, rename them to indicate which one they are, and keep them at the same level as the project file in the Finder. If they change location, change name, etc, the alias will have in it's Get Info, the original file's full path for later detective work to get the project compiling and linking again. (symlinks break too easy and are not natural to the Mac)
    • Last thing, and very important, see http://www.cocoawithlove.com/2008/10/using-libxml2-for-parsing-and-xpath.html where you can download XpathQuery and get some more goodness.

    hope this helps.

    If you happen to be developing something for Veterans, oh say an iPhone / iPad or Mac app, and are working against something called "MDWS" or "VIA" which are SOAP based interfaces to the medical record system... please contact me

    0 讨论(0)
  • 2020-11-27 11:06

    As of Mavericks (OS X 10.9) the /usr/include directory is gone. Half of the answers here are obsolete, as the application will not compile until you sort out the include directory.

    I solved the problem creating a symbolic link to MacOSX SDK in terminal, using the following command:

    sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include /usr/include
    

    The application now compiles again.

    0 讨论(0)
  • 2020-11-27 11:06

    I'm not sure what the difference is but add the include path to the project as well as the target.

    0 讨论(0)
  • 2020-11-27 11:07

    Form the link of @Matt Ball,

    I found following helpful to me.

    You need to add libxml2.dylib to your project (don't put it in the Frameworks section). On the Mac, you'll find it at /usr/lib/libxml2.dylib and for the iPhone, you'll want the /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/usr/lib/libxml2.dylib version.

    Since libxml2 is a .dylib (not a nice friendly .framework) we still have one more thing to do. Go to the Project build settings (Project->Edit Project Settings->Build) and find the "Search Paths". In "Header Search Paths" add the following path on the Mac:

     /usr/include/libxml2 
    
    0 讨论(0)
  • 2020-11-27 11:09

    You also need to add /usr/include/libxml2 to your include path.

    0 讨论(0)
  • 2020-11-27 11:11

    Ray Wenderlich has a blog post about using gdata that solves this problem. Basically these simple steps:

    In XCode, click Project\Edit Project Settings and make sure “All Configurations” are checked.

    Find the Search Paths\Header Search Paths setting and add /usr/include/libxml2 to the list.

    Finally, find the Linking\Other Linker Flags section and add -lxml2 to the list.

    original post: read and write xml documents with gdataxml

    0 讨论(0)
提交回复
热议问题