[cfe-dev] Use of libclang in OS X application

Jacob Carlborg via cfe-dev cfe-dev at lists.llvm.org
Mon Dec 14 09:40:44 PST 2015


On 2015-12-14 18:14, vivek pandya via cfe-dev wrote:
> 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

-- 
/Jacob Carlborg




More information about the cfe-dev mailing list