Ask Reuben
Link vs No Link
What is the difference between Genero and Genero (no link) ?
Do I have to perform a link if using IMPORT FGL?
When using Genero (no link), why is Compile File disabled?
In Genero Studio, if you Edit Build Rules and look at the Language field, you will see in the drop-down “Genero” and “Genero (no link)”. The question gets asked, what is the difference between these two options?
The answer in a roundabout way lies in the introduction of IMPORT FGL. If you go down the path of 100% IMPORT FGL, you no longer need the link stage.
Prior to IMPORT FGL, your build and run steps would use fglcomp, fgllink, and fglrun, and would look similar to …
fglcomp main.4gl
fglcomp filename.4gl
fgllink -o program.42r main.42m filename.42m
fglrun program.42r
Note : fgllink
is an alias of fglrun -l
, you might use fglrun -l
instead of fgllink
. Similarly fgl2p is a script that executes both the compilation and link steps, you might use fgl2p
in one step instead of seperate fglcomp
and fgllink
steps. I would encourage the seperate use of fglcomp
, fgllink
, and fglrun
commands as that helps reinforce the different steps that are occurring.
In the above example I am assuming that main.4gl contains the MAIN/END MAIN syntax, and that filename.4gl does not have a MAIN/END MAIN.
If instead at the top of main.4gl you had IMPORT FGL filename
your build and run steps are now …
fglcomp main.4gl
fglrun main.42m
If filename.4gl requires compiling, fglcomp main.4gl
will detect that and compile it as part of Auto-compilation of imported modules.
What does Genero Studio? If you go into the Build Rules configuration dialog you can see the commands that are executed for Genero and Genero (no link). For Genero we can see that it executes fglcomp
to compile a .4gl, and use fglrun -o
(the alias for fgllink) to link and build the .42r. This is similar to what I described above.
Looking at the same configuration for a Genero (no link) environment pictured below we see something very different. The Build Rule for a .4gl file is #
or nothing!!!. That is why the Compile File option is disabled. All the power is in the link stage where the work is in the following …
($(BuildOutputFilePaths:.42m))? $(echo) -n "$(BuildInputFilePaths:.4gl)" "$(IntermediateFilePaths:.4gl)" > "$(TargetDir)/$(BinaryName)_lst.txt"
($(BuildOutputFilePaths:.42m))? $(fglcomp) $(LinkerOptions) -o "$(TargetDir)" -Wall --make @"$(TargetDir)/$(BinaryName)_lst.txt"
What this is doing is building up a list of .4gl file in the *_lst.txt file and then passing that list to fglcomp –make ….
This –make option was something introduced in Genero 3.20 New Features and refined in later versions. It is a more efficient way of compiling many .4gl files, particularly if they use IMPORT FGL. This compiling in make mode ensure that each .4gl is compiled at most once.
So going back to original example, Genero Studio is doing equivalent of
fglcomp --make main.4gl filename.4gl
fglrun main.42m
Note: make sure that the application name in the project equals the name of the .4gl with the MAIN statement.
The Build Rules could be constructed so that the fglcomp is executed for each individual .4gl file and the link step being left with nothing to do, but then when you get into large projects with hundreds of files, there will be some overhead with the repeated fglcomp calls. Using fglcomp --make
will be quicker when there are a large number of files as there is only one fglcomp call.
If you decide to go down the path of 100% using IMPORT FGL and no linking, then consider using Genero (no link) inside Genero Studio, or if you stick to make file, investigate the use of fglcomp –make.