Contributed works of Danny A. del Pilar
How I can build a console application via HMG ?
We have a paradox here: though HMG is a GUI library, we are requesting a non-GUI service; since console means non-GUI.
But don’t wory, this is possible; even very easy, such as any HMG application, and with more than one method.
Method 1: Batch processing:
( Assuming HMG root folder is C:\hmg and name of your console application project file name is ConsOnly.HbP and your main prg file name is ConsOnly.Prg )
call c:\hmg\build.bat /c ConsOnly
( No matter ConsOnly is a project or program file. )
If your project has more than one .prg file, you may use build.bat such ways:
1- call c:\hmg\build.bat /c progr1 progr2 prog3 ...
2- First build a .hbp file contains such as:
and say name is “ConsOnly.Hbp” then invoke build.bat:
call c:\hmg\build.bat /c ConsOnly
The /c ( or /C ) switch inform build.bat about console.
You can omit this switch, by adding this line to top of your .prg file:
Method 2: Via HMG-IDE:
First you need add abowe
line to top of your .prg file.
And then, building a project file ( .hbp ). For example if your .prg file name is ConsOnly.prg, you may use a ConsOnly.HbP file contains one line:
If your project has more than one .prg file, your project file contains a list of that .prg files. For example:
You may build this project file simply writing with a text editor or by selecting “New Project” within HMG-IDE.
And only thing is pressing “Run” button.
Yo don’t need any other thing.
line into console-only .prg’s.
Technically no problem, you can add. Moreover with this way, though project is console mode, you can see error messages in GUI mode. But has a risk: may be some HMG functions have same names with Harbour and if you include “hmg.ch”, HMG functions will override others; an example may be BROWSE(). If this is your intend, no problem. But this situation sometime may be a nightmare.
How I can build a HMG applications ?
Build.Bat / HMG-IDE
The easiest way is to use the ‘build.Bat’ file located at \hmg folder.
Build [/i|/r|/d|/cs|/ci/cr] <PrgFile> | <filelist.hbp> [config.hbc]
[/i] : incremental build
[/r] : incremental build (rebuild all)
[/cs] : Console/mixed mode (std build)
[/ci] : Console/mixed mode (incremental build)
[/cr] : Console/mixed mode (incremental rebuild all)
[/d] : Debug mode (gui and console)
<filelist.hbp> : A text file with .hbp extension containing a source list.
<configfile.hbc>: A text file with configuration parameters as additional libs, include paths and lib paths.
incpaths = incpath1 incpath2 … incpathn
libpaths = libpath1 libpath2 … libpathn
libs = lib1 lib2 … libn
mt = yes (multi-threading support)
– library names must not include ‘lib’ prefix nor ‘.a’ extension.
– ‘build.bat’ will create an ‘error.log’ file in the app folder when build process ends with an error condition.
– <.hbc> files in the current folder are automatically processed.
– HMG IDE
This programming environment allows visual form editing and application build.
Environment settings (HMG Folder, Program Editor, etc.) are stored in ‘.ini’ files, located at IDE folder.You can interactively change default settings (Main Menu->Tools->Preferences).
In IDE, all build customizations must be handled by the user from ‘Configuration’ (project browser) tab. It is direct edit of the project .hbc file. Look at hbmk2 help for details. By default two gt drivers are ALWAYS linked: GTGUI (as default) and GTWIN (Windows console). To create console/mixed mode apps. you only must add this line to your main .prg: HB_GT_WIN_DEFAULT
When upgrading HMG, please, clean previous build data from your projects using incremental building. From command line, you must add the -clean parameter. From IDE, use the ‘Reset project incremental data’ option from the project menu.
Note: This post borrowed from official HMG Docs.
How I can build a Harbour applications ?
Method 1 : By batch processing:
First you have two path definition: harbour\bin and mingw\bin
If HMG installed in your PC, harbour and mingw directories are already exists. If your HMG root <dir> is c:\hmg, harbour\bin is :
and your mingw\bin is
If HMG not installed or you want use other than HMG folders, you will change paths definitions according to your choice.
Than for this path definitions you will enter (preferably by a a .bat file ) a command like this:
After run this batch file, it’s sufficient a single command for build your application ( in your working directory including <MyProg> of course ):
hbmk is probably ultimate utility in make area; extremely versatile and extremely successful.
By command window (after changing current directory to harbour\bin or setting path as mentioned below) enter
(without any more world) for short help and
for long one.
More detailed help may find in Harbour Project users’ mailing list.
Method 2 : By hbIDE
( With words of author, Pritbal Bedi) hbIDE, as the name implies, Harbour’s Integrated Development Environment, is an open-source, multi-platform, project. hbIDE is aimed at simplifying the process of project life-cycle comprising, setting-up the project components, editing the sources, building them to final binaries.
How I can build Harbour and / or HMG?
Harbour and HMG both are open source project and it’s possible to (re)build them in your own machine.
But before we need find an answer to the question “why?”. Both projects has their own binary ( executables, libs, etc ), even setup prg. If you want play on source code, surely you will find building method(s) by digging package.
Making some change in the source code may be educative, useful for understand more deeply the system; but sometime may be also annoying.
First changing system source files will be risky in general; while changing some place, will be problematic other places, and at least you have make same change repeatedly for every next release of compiler / library.
And second, you have re-build compiler / library for every change you made.
There is a mymake.bat and win-mak.exe in Harbour package and HMG has buildlib.bat .
And, an excellent tutorial How to build HARBOUR … by an excellent Harbour fan: Giovanni Di Maria.
Anyway, since primary goal is address to beginners, details of this issue is out of scope of this blog.