Using LLVM JIT inside a Cocoa application


I am trying to compile a project I am writing with Xcode that will use
LLVM libraries to generate code executed with the JIT.
I would be curious to learn how you deal with LLVM header files,
libraries, makefiles and Cocoa application projects.

My candid understanding is that LLVM projects need to be built with
LLVM makefiles (hence the previous message I sent about LLVM
Projects). I am not totally reluctant to the idea of building a
library outside of Xcode and then linking it to my Cocoa project, but
I find it rather annoying to maintain two project structures. With
some work it would be possible to automate all of this build project
inside Xcode, but I was hoping a more straightforward solution.

Any ideas?

Best Regards,


I'm not an LLVM expert, but I think you can build a Cocoa/LLVM project by using the LLVM's libraries and headers the same way you did with any other third party library.

In fact, that's what the clang Xcode project does. It does not use any makefile.

In short:
  - Add the llvm/include folder in you header search path (in the project's build settings).

To add libraries, an option may be to drop the *.a you need in your Xcode project, and Xcode is smart enough to adjust the library search path as needed.

and other option (the one chosen by clang) may be to change build settings:
  - Add the llvm/<output>/lib/ folder in you library search path (replace <output> by the name of the llvm build dir. You can choose a value based on your build configuration to use different libraries variant in Debug and Release).
  - Add linker flags to tell the linker which LLVM libraries you want to use.

Bonjour Jean-Daniel,

I didn't know about the clang Xcode project, and indeed it works very naturally.
It seems the key to successfully build a project within Xcode is to set :


I was fearing the makefiles were involving more work behind the
scenes, but that's not true: include the headers, libraries, and set
the C++ macros.

Thanks for the info!