Compiling project with g++ built in

David Brown david@westcontrol.com
Fri Sep 5 12:17:00 GMT 2014


On 05/09/14 09:49, Phil Freeman wrote:
> To-whom-it-may-concern,
> 
> I'm developing a number of software pieces (plugins) for a well known
> animation package, and I'm wishing to look into the possibility of
> using the c++ equivalent of the gnu gcc inside of one of the plugins.
> The purpose of this particular plugin is to allow users to build
> their plugins from inside the animation package, using my plugin.
> 
> I've come across gnu gcc through general Google searches, but am a
> little confused in what I've read over so far. A lot of what I've
> read seems to be how to compile something with gcc, whereas I'm
> wanting to know how I can compile my project with the gcc compile
> engine inside my plugin.
> 
> My lack of general c++ knowledge (and not being able to talk the
> programmers lingo) puts me in an awkward position in that I can
> competently program plugins using the available animation package's
> sdk, but anything outside those boundaries can at times leave me a
> little lost - which is why I've ended up here!
> 
> Is there a forum somewhere that I can sign up too, to seek support
> for implementing the c++ equivalent compiler into the mentioned
> plugin? If not, is there someone whom I can possibly contact and bug
> to get me going in the right direction? Or have I misunderstood what
> gnu gcc is all about?
> 
> If it helps, I'm building the plugin in VS 2010 express, and the end
> result is a dll library file - albeit with another extension. I'm
> wishing to build the plugin so that the end user has only the one
> single plugin file, with the compiler engine fully built into the
> plugin. The plugin itself will need to compile a dll file, but with
> another extension.
> 
> Any help would be much appreciated. Kind regards,
> 

I think it sounds unlikely that you can get everything into a dll.  For
one think, a compiler toolchain (especially C++) is large - a gcc
installation is typically something like 200 MB.  If we are generous and
assume that LLVM (as mentioned by Jonathan) is much more efficient than
gcc, and we cut out anything unnecessary (such as documentation), you
could maybe cut it down to about 50 MB.  The other issue is that the C++
toolchain consists of multiple files - there are preprocessors,
compilers, assemblers, linkers, library files, header files, etc.  It is
going to be almost impossible to change the system to avoid needing
separate files.  At best, your dll would need to pack out the files into
a temporary tree and run them from there, then clear them up afterwards
- that's going to be massively inefficient.

Then there is the licensing issue.  gcc places no restrictions on the
license of files you compile or link with it - but the toolchain itself
is under the GPL.  If your code is integrated with gcc, then that means
your code also needs to be under the GPL (though you can still use it to
/generate/ code with any license).  This may or may not suit your
requirements.


LLVM would definitely be easier than gcc in all respects mentioned here,
and is a more suitable choice of toolchain for such uses.  But it will
still not be an easy task - especially fitting everything into one dll.


I think a much more efficient mechanism would be for your plugin to
support using a user-installed compiler, and let the user install
whatever C++ toolchain they want to use (such as MSVS, or a real
compiler like gcc or llvm).  Then your issues about installing and
packaging a C++ toolchain have been reduced to a documentation issue of
pointing the user at the appropriate download page.





More information about the Gcc-help mailing list