Using gec PreviousNext

Command-line options

The usual way to invoke gec is as follows:

gec ace_filename
This will read the description of your program in the Ace file ace_filename, compile it and invoke the back-end C compiler on the generated C code as explained below. Here is a list of options that can be used with gec:
-h
--help
Print a summary of the command-line options of gec and exit.
--finalize
Compile with optimizations turned on.
--cat
CAT-call errors should be considered as fatal errors.
--split=<no|yes>
Should generated C code be split over several C files instead of being held in a single possibly large C file? (default: yes)
--split-size=<size>
Size (in bytes) of generated C files in bytes when in split mode
--cc=<no|yes>
Should the back-end C compiler be invoked on the generated C code? (default: yes)
--gc=<no|boehm>
Which garbage collector should the application be compiled with? (default: no)
--silent
Run gec in silent mode.
--verbose
Run gec in verbose mode.
-V
--version
Print the version number of gec and exit.

Ace files

An Ace file contains the description of the Eiffel program to be compiled. gec is able to read the same Ace files as ISE Eiffel. So if you already have your Ace files the only thing you have to do is to instruct gec to use FreeELKS kernel classes instead of ISE EiffelBase kernel classes. To do so you just have to replace the EiffelBase clusters in your Ace file by:

all free_elks: "${GOBO}/library/free_elks"
If you are new to Eiffel and don't know what an Ace file is, please have a look at this description from the documentation of the Gobo Eiffel Tools Library on which gec is based.

Back-end C compiler

gec translates your Eiffel programs into C code. This C code is then passed to a back-end C compiler to generate an executable. By default gec uses Microsoft Visual C cl on Windows and GNU gcc on other operating systems such as Linux. This section explains how to override this default if you want to use another back-end C compiler or if you want to specify different C compilation options.

For each C compiler that you want to use as back-end C compiler, you should provide a config file that should be located in $GOBO/tool/gec/config/c/. Here is an example of such config file, gcc.cfg for the gcc compiler:

cc: gcc $cflags $includes -c $c
link: gcc $lflags -lm -o $exe $objs $libs
obj: .o
exe:
cflags: 
lflags:
cflags_finalize: -O2
lflags_finalize:
This config file is used by gec to generate a .bat file on Windows or a shell script on other platforms that will be executed to compile the generated C code. The variable "cc" represents the command-line template to turn C files into object files, and "link" to turn object files into executables. The variables "$cflags", "$includes", "$c" in the first template, and "$lflags", "$exe", "$objs" and "$libs" in the second template will be replaced by appropriate values by gec. Next, the variables "obj" and "exe" represent the file extensions for object files and executables on the platform on which this C compiler will be invoked. And finally we find C compilation and linker flags that should be used when gec is invoked with or without the command-line option "--finalize". Note that Eiffel-style comments, starting with "--", can be included in these config files.

There are several ways to instruct gec to use a different back-end C compiler. You can either write the name of the chosen C compiler in the file $GOBO/tool/gec/config/c/default.cfg. You might need to create this file if it does not exist yet. Alternatively you can specify the name of the chosen C compiler in the environment variable $GOBO_CC. Let's say that the name of your chosen C compiler is my_cc. gec will then look for the config file $GOBO/tool/gec/config/c/my_cc.cfg.


Copyright 2006-2016, Eric Bezault
mailto:ericb@gobosoft.com
http://www.gobosoft.com
Last Updated: 27 December 2016
HomeTocPreviousNext