|in memory compiling? firstname.lastname@example.org (2004-04-15)|
|Re: in memory compiling? email@example.com (Basile Starynkevitch \[news\]) (2004-04-15)|
|From:||"Basile Starynkevitch \[news\]" <firstname.lastname@example.org>|
|Date:||15 Apr 2004 20:27:17 -0400|
|Organization:||http://starynkevitch.net - Ours|
|Posted-Date:||15 Apr 2004 20:27:17 EDT|
Le 15-04-2004, rtischer <email@example.com> a écrit :
> I need to compile C++ to memory instead of a file. Does anyone know if
> any well-known compilers have an option for code placement?
I don't know of any (open-source) compiler for C++ generating code in
memory. However (at linux on most Unix or Linux system) you could
generate a shared object file .so and use dlopen() to load it
If you accept to use only C and not C++, you can use, on Linux/x86
systems, the tinycc compiler (tcc), which can compile into memory. See
http://tinycc.org/ for more. Tcc generate machine code vey quickly,
but the generated code is less optimised (and about 10-30% slower)
than what GCC produces (with optimisations enabled).
An alternative could be to use some library generating machine code
into memory. I did use successfully for that purpose the GNU lightning
library (I suggest using the latest CVS snapshot from
savannah.gnu.org). GNU lightning run on x86, Sparc, PowerPC (all in 32
By the way, C++ is quite complex to compile (even to parse) and
usually requires many #include-d files in practical programs (in
particular, those using templates and other C++ fancy features), so
you won't win much to compile into memory. In other words, why don't
you compile your C++ code into a file?
Please note also that several language implementations
(e.g. CommonLisp as SBCL...) give you the ability to generate machine
code into memory with great ease. Perhaps your C++ requirement could
be softened to something more appropriate for your task..
Basile STARYNKEVITCH http://starynkevitch.net/Basile/
aliases: basile<at>tunes<dot>org = bstarynk<at>nerim<dot>net
8, rue de la Faïencerie, 92340 Bourg La Reine, France
Return to the
Search the comp.compilers archives again.