Use of libclang in OS X application

Hello ,

I want to use libclang with Swift in OS X application. Please suggest me whether I should use static(.a) or dynamic(.dylib) libclang ? In both the case what are the other dependencies needs to be included ? If I use .dylib version then Can it be distributed as a single executable which is independent and deployed on OS X machine which do not have XCode or clang installed ?

I have build static libclang with cmake -DLIBCLANG_BUILD_STATIC=ON but it generated both for me .a and .dylib . Why size of .dylib is greater than .a file ?

Please guide .

Hello ,

I want to use libclang with Swift in OS X application. Please suggest me
whether I should use static(.a) or dynamic(.dylib) libclang ? In both
the case what are the other dependencies needs to be included ? If I use
.dylib version then Can it be distributed as a single executable which
is independent and deployed on OS X machine which do not have XCode or
clang installed ?

Clang itself is not required but its internal headers are required. They way I solved this in my tool [1] was to include (some of) the headers in the executable itself and then used CXUnsavedFile to create something like a virtual file. The the path to the virtual file is added by the tool to the command line arguments used by libclang to parse the translation unit.

Perhaps not ideal, but that's the best I could think of.

I have build static libclang with |cmake -DLIBCLANG_BUILD_STATIC=ON but
it generated both for me .a and .dylib . Why size of .dylib is greater
than .a file ?

If there's a big difference I would guess the static library depends on other (Clang/LLVM) libraries that need to be linked as well.

[1] https://github.com/jacob-carlborg/dstep/commit/3199b109b5d5c8420328be8d8dc948822fd451da