Using gec | ![]() ![]() |
The usual way to invoke gec is as follows:
gec ecf_filenameThis will read the description of your program in the ECF file ecf_filename, compile it and invoke the back-end C compiler on the generated C code as explained below.
For simple programs, one can just provide the Eiffel file containing the root class:
gec eiffel_filenameHere is the list of options that can be used with gec:
It is possible to override some of the command-line options above, or the default values for these options, using environment variables.
An ECF file contains the description of the Eiffel program to be compiled. gec is able to read the same ECF files as ISE Eiffel. So if you already have your ECF files, you can use them without any modifications with gec.
If you are new to Eiffel and don't know what an ECF file is, please have a look at this description from the documentation of the Gobo Eiffel Tools Library on which gec is based.
Note that for simple programs like a hello_world program, it is not necessary to provide an ECF file. You can just let gec know in which Eiffel file it can find the root class of the Eiffel system:
gec hello_world.eIt will use the first creation procedure declared in the `create` clause of the root class as root creation procedure. This will work fine provided that all classes used in your simple program are part of one of the libraries provided in the Gobo Eiffel Project. You can give it a try using the HELLO_WORLD class provided in $GOBO/library/common/example/hello_world/hello_world.e. An ECF file will be needed when you want to use classes from other libraries or if you want to override the default settings (e.g. console application, SCOOP mode).
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 the Zig toolchain which is included into the Gobo Eiffel package. 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/backend/c/config/. Here is an example of such config file, gcc.cfg for the gcc compiler:
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.cc: gcc $cflags $includes -c $c link: gcc $lflags -lm -o $exe $objs $libs obj: .o exe: cflags: lflags: cflags_finalize: -O2 lflags_finalize:
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/backend/c/config/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/backend/c/config/my_cc.cfg.
Copyright © 2006-2025, Eric Bezault mailto:ericb@gobosoft.com https://www.gobosoft.com Last Updated: 31 August 2025 |
![]() ![]() ![]() ![]() |