Issue #3 new

libclang headers do not ship with Xcode

Tobias Braun
created an issue

This is what I did:

  1. Cloned tip (9b155ec) using hg on the command line.
  2. Ran xcodebuild (no arguments) in the cloned directory.

This is what I got:

IDE/ZCTextEditorViewController.h:36:9: fatal error: 'Index.h' file not found

System information:

  • 64-bit Intel
  • OS X 10.7.5
  • Xcode 4.6.2

Maybe this is the same issue as #2, but I am opening another ticket anyway as #2 might also be something else, since there is next to no information in that ticket.

I'll be glad to provide further details if you tell me what info you need.

Comments (13)

  1. Ivan Vučica repo owner

    Hello Tobias,

    First, thanks for looking at the project, and thanks for reporting this!

    Looking at the project, I see that I have used an installation of libclang in /opt/local/include/clang-c, almost certainly pulled from MacPorts years ago. Unfortunately, I am not under OS X at the moment (and I definitely don't have a clean installation at the moment!) so I would appreciate if you could try finding a copy of Index.h on your machine that relates to clang or llvm in any way.

    I tried quickly looking into Xcode.app as much as I could under Windows, and I can't find this header.

    If it turns out that I didn't look hard enough and that libclang along with its headers ships with stock Xcode, then updating the project file to point to this header directory is the best way to handle this. Otherwise, I should probably document that people should define HAVE_LIBCLANG=0 instead of 1 until they install libclang from MacPorts, or possibly Homebrew, or another repository. Or even llvm repositories.

  2. Tobias Braun reporter

    Hello Ivan,

    find / -name Index.h 2> /dev/null

    didn't turn up anything, so I guess the headers do not ship with Xcode's default install.

    libclang by itself doesn't seem to be available in Homebrew. I wouldn't mind installing llvm via Homebrew, but can I safely do so without the Homebrew install interfering with the default llvm install? What will Xcode use after I have installed llvm via Homebrew? Which version will be executed when I type clang on the command line?

  3. Ivan Vučica repo owner

    Hello Tobias,

    Unfortunately, I can't vouch whether there will be any conflicts -- but Xcode does seem very good at pulling in the embedded clang in place of whatever else you may have installed.

    The version that'll be run on CLI depends on your PATH environment variable, but will probably be whatever you install through Homebrew or MacPorts.

    I don't think OS X ships with Clang anyway; whatever /usr/bin/clang you might have right now probably came with Xcode and was possibly copied by xcode-select. And since generally nothing should write in OS X's system folders (which, aside from /System, includes /bin/, /sbin/, /lib/, as well as /usr/ apart from /usr/local/), then I suspect you won't have trouble by installing a different clang.

    And even if you do -- we're all grownups here, what harm did a little bit of playing with fire ever do that a Time Machine could not fix? :-)

  4. Tobias Braun reporter

    Hello Ivan,

    I haven't tried installing libclang yet, but I set HAVE_LIBCLANG to 0, as you suggested. It eventually worked, however I had to #if out a few pieces of code first. I also had to remove the links to the clang/llvm libraries which were present in the project but broken. (probably due to version differences)

  5. Ivan Vučica repo owner

    Your patches will be very welcome, especially the changes to source code :-)

    While I cannot work on Zcode at this time, I'd love it if it were as easily compilable out of the box as possible.

  6. Tobias Braun reporter

    I'll gladly provide a patch, but I have never contributed code to an open source project before. Could you please tell me what I have to do exactly?

  7. Ivan Vučica repo owner

    Since this is a private toy project of mine, I am not largely interested in copyright assignment or such legal issues. (Besides, small changes are quite possibly not copyrightable.)

    So:

    1. Clone Zcode on BitBucket (there should be a button entitled "Fork" or "Clone" or something like that).
    2. Do your changes.
    3. Commit your changes.
    4. Push your changes to your URL instead of Zcode URL.
    5. Go to BitBucket and create a "pull request", so that I'm notified and so that I can easily merge your changes.
  8. Tobias Braun reporter

    Copyright issues weren't on my mind at all when I was writing my previous post. :-) The steps you wrote down are exactly the instructions I was looking for.

    One question arises, though: In order for my changes to be of any effect, I'd have to set HAVE_LIBCLANG to 0. Should I include that change to the Xcode project file in the commit? Or should I just hg revert the changes to that file before committing?

  9. Tobias Braun reporter

    As you can see, I'm pretty good as well when it comes to delayed responses. :) But I finally just created the pull request.

    I did, however, set HAVE_LIBCLANG=0, as I had to make further modifications to the project file anyway in order to get it to compile. But I guess you can just pull in the source changes and ignore the changes to the project file.

  10. Ivan Vučica repo owner

    Tobias Braun - thanks for contributing cf32f5c. I'll leave the bug open to track the fact that libclang headers are not available with Xcode, and that the project actually does not compile unless people manually install libclang, or set HAVE_LIBCLANG=0 + adjust build rules the way you did.

    Other people can temporarily use your changeset, but I'll leave the bug open for the months-in-the-future situation when I'll be looking at Zcode again.

  11. Log in to comment