Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a library that can compile C++ or C

I came here to ask this question because this site has been very useful to me in the past, seems to have very knowledgeable users who are willing to discuss a question even if it is metaphysical at times. And also because googling it did not work.

Java has a compiler and then it has a JDT library that can compile java on the fly (for example used in JasperReports to turn a report template into Java code).

My question: Does anyone know of a library/project that would offer compiling as a set of library classes in c/c++. For example: a suite of classes to perform Preprocessing, Parsing, CodeOptimization and of course Binary rendering to executable images such as ELF or Win format. Basically something that would allow one to compile c or c++ scriptlets as part of an application.

like image 315
640KB Avatar asked Oct 26 '10 22:10

640KB


People also ask

Can I compile C in Visual Studio?

The Visual Studio build tools include a C compiler that you can use to create everything from basic console programs to full Windows Desktop applications, mobile apps, and more.

Are there C libraries?

A library in C is a collection of header files, exposed for use by other programs. The library therefore consists of an interface expressed in a . h file (named the "header") and an implementation expressed in a . c file.

What compiler can be used for C?

There are many compilers for C, but we will focus on a free open source version called the Gnu C compiler. (Actually we will use the Gnu C++ compiler, but all C programs compile using this compiler).

Can G ++ compile C?

gcc is used to compile C program. g++ can compile any . c or . cpp files but they will be treated as C++ files only.


2 Answers

Yes: llvm. In particular, clang. At least, that's how they advertise the projects. Also, check this question. It might be relevant if you decide to use llvm.

like image 112
andref Avatar answered Oct 21 '22 02:10

andref


You might be able to adapt something from the LLVM project to your needs.

like image 26
Jack Kelly Avatar answered Oct 21 '22 03:10

Jack Kelly