Compile OpenCL host code using Clang and LLVM


I’m working now in a program in C++ that analyses OpenCL kernel codes using Clang (using Clang C++ functions, not Clang command-line instructions). Moreover, my program also have to be able to compile a given C++ host code for the kernel analysed, but now I’m doing the compilation with “system(g++ …)”.

My question is: Is it possible to, given a C++ source code file (a simple .cpp file), compile it from my program (without using command-line instructions), just calling Clang and LLVM functions?

Thank you so much in advance.