[Harbour-users] Question for FAQ: "How to compile a hello world
program?"
smu johnson
smujohnson at gmail.com
Thu Jan 21 04:57:28 EST 2010
Thanks everyone. I appreciate all the replies greatly. I don't understand
why this wouldn't be in the FAQ, when questions like "What is Harbour?" are
in there. I am skeptical that that question is actually a "Frequently asked
question". I will keep a journal of my attempts to get Harbour working
properly by piecing it together with everyones help and my own effort.., and
at the end, suggest a few important yet pertinent questions for the FAQ.
Looking forward to Harbour!
On Wed, Jan 20, 2010 at 11:08 PM, Massimo Belgrano <mbelgrano at deltain.it>wrote:
> Using hbmk2
>
>
> hbmk2 is a Tool that allow compile sample and large project
> basic use of this tools is
> hbmk2 ac_test
> hbmk2 ac_test.prg
> After this command you have ac_test.exe created
> You can also immediaply execute simple using
> hbmk2 ac_test -run
>
> Hbmk2 is indipendent from Platform and Compiler that you use
>
> Please also try the recommended way with hbmk2, it does
> a similar job to your manual Makefile, but it's portable, works
> for all future test programs and just one line.
>
> If hbmk2 doesn't work for you for some reason, post your -trace output
>
> How compile several. PRG & lib?
>
> hbmk2 test1 test2 testn -lmylib1 -lmylib2 -lmylibn
> hbmk2 test1.prg test2.prg testn.prg mylib1.lib mylib2.lib mylibn.lib
>
> How create a lib?
>
> hbmk2 myprg1.PRG myprg2.prg myrc.rc -b -m -hblib -omiolib.lib
>
> How have additional information?
>
> hbmk2 test1 test2 testn -lmylib1 -lmylib2 -lmylibn
> hbmk2 ac_test -info -trace
>
> How disample compile incremental?
>
> hbmk2 test1 test2 testn -lmylib1 -lmylib2 -lmylibn -rebuild
> default os enable incremental build mode , so only modified part of
> your project will be recompiled
> -rebuild flag allow
> How use a config library file (hbc)?
>
> hbc contain the library used from the project
> typically exist a template for each library for include all neccessary
> references
> se for eaxample
> /harbour/contrib/hbxbp/hbxbp.hbc
> Yoy can use use hbc adding to hbmk2 command line
> use inside a hpb adding a line with path where hbc reside
>
>
> #
> # $Id: hbxbp.hbc 11447 2009-06-20 02:41:38Z vszakats $
> #
>
> incpaths=.
>
> libs=hbxbp
> libs=../hbqt/hbqt.hbc
> How used a Project file (hbp)?
>
> you can simply use
> hbmk2 hbide.hbp
> hbp contain all command contained in command line
> #
> # $Id: hbide.hbp 13463 2010-01-04 10:15:18Z vouchcac $
> #
>
> ../hbxbp/hbxbp.hbc
>
> -inc
>
> -w3 -es2 -gc3
>
> -ohbide
>
> # Trick to make it link using default Harbour builds
> -ldflag={msvc}-nodefaultlib:msvcrt.lib
> -ldflag={msvc}-defaultlib:libcmt.lib
>
> hbide.prg
> ideobject.prg
> idestylesheets.prg
> idetags.prg
> idemisc.prg
> ideactions.prg
> ideeditor.prg
> idefindreplace.prg
> idedocks.prg
> idesaveload.prg
> iderequests.prg
> idethemes.prg
> ideprojmanager.prg
>
> ideparseexpr.c
>
> What is hb.mk?
>
> Is a default setting applied to all source compiled in this directory
> How obain help?
>
> hbmk2 - help
>
> Harbour Make (hbmk2) 2.0.1dev (Rev. 13476)
> Copyright (c) 1999-2010, Viktor Szakats
> http://www.harbour-project.org/
> Translation (it-IT): (add your name here)
>
> Syntax:
>
> hbmk2 [options] [<script[s]>]
> <src[s][.prg|.c|.obj|.o|.rc|.res|.po|.pot|.hbl|@.clp|.d]>
>
> Options:
> -o<outname> output file name
> -l<libname> link with <libname> library. <libname> should be
> without
> path, extension and 'lib' prefix (unless part of
> libname).
> -L<libpath> additional path to search for libraries
> -i<p>|-incpath=<p> additional path to search for headers
> -static|-shared link with static/shared libs
> -mt|-st link with multi/single-thread VM
> -gt<name> link with GT<name> GT driver, can be repeated to link
> with
> more GTs. First one will be the default at runtime
> -hblib create static library
> -hbdyn create dynamic library
>
> -gui|-std create GUI/console executable
> -main=<mainfunc> override the name of starting function/procedure
> -fullstatic link with all static libs
> -[full|fix]shared create shared Harbour binaries without/with absolute
> dir
> reference to Harbour library (default: 'fullshared'
> when
> Harbour is installed on system location, 'fixshared'
> otherwise) (fix/full option in *nix only)
> -nulrdd[-] link with nulrdd
> -[no]debug add/exclude C compiler debug info. For Harbour level
> debug, use Harbour option -b as usual
> -[no]optim toggle C compiler optimizations (default: on)
> -[no]cpp[=def] force C/C++ mode or reset to default
> -[no]map create (or not) a map file
> -[no]implib create (or not) an import library (in -hbdyn mode)
> -[no]strip strip (no strip) binaries
> -[no]trace show commands executed
> -[no]beep enable (or disable) single beep on successful exit,
> double
> beep on failure
> -[no]ignore ignore errors when running compiler tools (default:
> off)
> -nohblib[-] do not use static core Harbour libraries when linking
> -nolibgrouping[-] disable library grouping on gcc based compilers
> -nomiscsyslib[-] don't add extra list of system libraries to default
> library list
> -traceonly show commands to be executed, but don't execute them
> -[no]warn[=lev] set C compiler warning level
> <lev> can be: yes, no, def (default: yes)
> -[no]compr[=lev] compress executable/dynamic lib (needs UPX)
> <lev> can be: min, max, def
> -[no]run run/don't run output executable
> -vcshead=<file> generate .ch header file with local repository
> information. SVN, CVS, Git, Mercurial, Bazaar and
> Fossil
> are currently supported. Generated header will define
> macro _HBMK_VCS_TYPE_ with the name of detected VCS and
> _HBMK_VCS_ID_ with the unique ID of local repository
> -tshead=<file> generate .ch header file with timestamp information.
> Generated header will define macros _HBMK_BUILD_DATE_,
> _HBMK_BUILD_TIME_, _HBMK_BUILD_TIMESTAMP_ with the
> date/time of build
> -icon=<file> set <file> as application icon. <file> should be a
> supported format on the target platform (experimental)
> -instpath=<path> copy target to <path>. if <path> is a directory, it
> should
> end with path separator. can be specified multiple
> times
> -nohbc do not process .hbc files in current directory
> -stop stop without doing anything
> -echo=<text> echo text on screen
>
> -bldf[-] inherit all/no (default) flags from Harbour build
> -bldf=[p][c][l] inherit .prg/.c/linker flags (or none) from Harbour
> build
> -inctrypath=<p> additional path to autodetect .c header locations
> -prgflag=<f> pass flag to Harbour
> -cflag=<f> pass flag to C compiler
> -resflag=<f> pass flag to resource compiler (Windows only)
> -ldflag=<f> pass flag to linker (executable)
> -aflag=<f> pass flag to linker (static library)
> -dflag=<f> pass flag to linker (dynamic library)
> -runflag=<f> pass flag to output executable when -run option is used
> -jobs=<n> start n compilation threads (multiprocess platforms
> only)
> -inc enable incremental build mode
> -[no]head[=<m>] control source header parsing (in incremental build
> mode)
> <m> can be: native, full, partial (default), off
> -rebuild rebuild all (in incremental build mode)
> -clean clean (in incremental build mode)
> -workdir=<dir> working directory for incremental build mode
> (default: .hbmk/plat/comp)
>
> -hbl[=<output>] output .hbl filename. %{hb_lng} macro is accepted in
> filename
> -lng=<languages> list of languages to be replaced in %{hb_lng} macros in
> .pot/.po filenames and output .hbl/.po filenames. Comma
> separared list:
> -lng=en-EN,hu-HU,de
> -po=<output> create/update .po file from source. Merge it with
> previous
> .po file of the same name
> -[no]minipo don't (or do) add Harbour version number and source
> file
> reference to .po (default: add them)
> -rebuildpo recreate .po file, thus removing all obsolete entries
> in
> it
>
> -target=<script> specify a new build target. <script> can be .prg (or no
> extension) or .hbm file (available on command line
> only)
> -target marks beginning of options belonging to a new build
> target
> (available on command line only)
> -alltarget marks beginning of common options belonging to all
> targets
> (available on command line only)
>
> -hbrun run target
> -hbraw stop after running Harbour compiler
> -hbcmp|-clipper stop after creating the object files
> create link/copy hbmk2 to hbcmp/clipper for the same
> effect
> -hbcc stop after creating the object files and accept raw C
> flags
> create link/copy hbmk2 to hbcc for the same effect
> -hblnk accept raw linker flags
> -hb10 enable Harbour 1.0.x compatibility mode (experimental)
> -xhb enable xhb mode (experimental)
> -hbc enable pure C mode (experimental)
> -exospace emulate Clipper compatible linker behavior
> create link/copy hbmk2 to rtlink/blinker/exospace for
> the
> same effect
>
> -hbmake=<file> convert hbmake project file to .hbp file (experimental)
> -xbp=<file> convert .xbp (xbuild) project file to .hbp file
> (experimental)
> -xhp=<file> convert .xhp (xMate) project file to .hbp file
> (experimental)
>
> --hbdirbin output Harbour binary directory
> --hbdirdyn output Harbour dynamic library directory
> --hbdirlib output Harbour static library directory
> --hbdirinc output Harbour header directory
>
> -plat[form]=<plat> select target platform.
> -comp[iler]=<comp> select C compiler.
> Special value:
> - bld: use original build settings (default on *nix)
> -build=<name> use a specific build name
> -lang=<lang> override default language. Similar to HB_LANG envvar.
> --version display version header only
> -pause force waiting for a key on exit in case of failure
> (with
> alternate GTs only)
> -info turn on informational messages
> -quiet suppress all screen messages
>
> Notes:
> - <script> can be <@script> (.hbm format), <script.hbm>, <script.hbp>
> (marks
> a new target) or <script.hbc>.
> - Multiple -l, -L and <script> parameters are accepted.
> - Regular Harbour compiler options are also accepted.
> - hbmk.cfg option file in hbmk2 directory is always processed if it
> exists.
> On *nix platforms ~/.harbour, /etc/harbour, <base>/etc/harbour,
> <base>/etc
> are checked (in that order) before the hbmk2 directory. The file format
> is
> the same as .hbc.
> - hbmk.hbm make script in current directory is always processed if it
> exists.
> - .hbc config files in current dir are automatically processed.
> - .hbc options (they should come in separate lines): libs=[<libname[s]>],
> hbcs=[<.hbc file[s]>], gt=[gtname], syslibs=[<libname[s]>],
> prgflags=[Harbour flags], cflags=[C compiler flags], resflags=[resource
> compiler flags], ldflags=[linker flags], libpaths=[paths],
> sources=[source
> files], incpaths=[paths], inctrypaths=[paths], instpaths=[paths],
> gui|mt|shared|nulrdd|debug|opt|map|implib|strip|run|inc=[yes|no],
> cpp=[yes|no|def], warn=[yes|no|def], compr=[yes|no|def|min|max],
> head=[off|partial|full|native], skip=[yes|no], echo=<text>
> Lines starting with '#' char are ignored
> - Platform filters are accepted in each .hbc line and with several
> options.
> Filter format: {[!][<plat>|<comp>|<keyword>]}. Filters can be combined
> using '&', '|' operators and grouped by parantheses. Ex.: {win}, {gcc},
> {linux|darwin}, {win&!pocc}, {(win|linux)&!watcom}, {unix&mt&gui},
> -cflag={win}-DMYDEF, -stop{dos}, -stop{!allwin},
> {allpocc|allgcc|allmingw|unix}, {allmsvc}, {x86|x86_64|ia64|arm},
> {debug|nodebug|gui|std|mt|st|xhb}
> - Certain .hbc lines (libs=, hbcs=, prgflags=, cflags=, ldflags=,
> libpaths=,
> inctrypaths=, instpaths=, echo=) and corresponding command line
> parameters
> will accept macros: ${hb_root}, ${hb_dir}, ${hb_name}, ${hb_plat},
> ${hb_comp}, ${hb_build}, ${hb_cpu}, ${hb_bin}, ${hb_lib}, ${hb_dyn},
> ${hb_inc}, ${<envvar>}. libpaths= also accepts %{hb_name} which
> translates
> to the name of the .hbc file under search.
> - Options accepting macros also support command substitution. Enclose
> command
> inside ``, and, if the command contains space, also enclose in double
> quotes. F.e. "-cflag=`wx-config --cflags`", or
> ldflags={unix&gcc}"`wx-config --libs`".
> - Defaults and feature support vary by platform/compiler.
> - Options can also be specified in environment variable HBMK_OPTIONS
>
> Supported <comp> values for each supported <plat> value:
> - linux : gcc, clang, icc, watcom, sunpro, open64
> - darwin : gcc, clang, icc
> - win : mingw, msvc, bcc, watcom, icc, pocc, cygwin, xcc,
> - mingw64, msvc64, msvcia64, iccia64, pocc64
> - wce : mingwarm, mingw, msvcarm, poccarm
> - os2 : gcc, gccomf, watcom
> - dos : djgpp, watcom
> - bsd : gcc
> - hpux : gcc
> - beos : gcc
> - sunos : gcc, sunpro
>
>
>
>
> 2010/1/21 smu johnson <smujohnson at gmail.com>:
> > Hi.
> >
> > I have installed Harbour on my Windows 64 machine... but have absolutely
> no
> > clue how to use this. It just installed, and I have a tree with a bunch
> of
> > executables.
> >
> > If I wanted to write a hello world program (which I have done), what
> steps
> > must I take to actually be able to use Harbour as intended... ie, make a
> > hello.exe file?
> >
> > I am surprised that nowhere in the FAQ is this question answered, or even
> > addressed. I feel like I missed the school day when "how to generate,
> > compile, link, and make .exe" discussions were held.
> >
> > I tried to experiment, and ran C:\>harbour hello.prg. Now I have a C
> file
> > generated... I don't understand in a harbour context what I'm susposed to
> do
> > with this. Obviously it won't compile without a few arguments to MinGW
> or
> > gcc. Since I couldn't find any hints or explanations, I tried
> compiling
> > it on my Linux machine as it has gcc setup easily, and it complains about
> > missing headers, which I kind of guessed would happen. So, maybe the
> most
> > obvious question of all for the FAQ: "I installed Harbour. How do I
> make
> > an .exe from a helloworld.prg file?" or something to that effect.
> >
> > Am I simply missing a simple batch file that will just do all this
> linking
> > work for me, so that hello.prg turns into an .exe without any fuss or
> > frustration? Could someone please kindly explain what I am missing?
> Since
> > old DOS apps like Turbo C or Pascal, or Microsoft Basic let you do this
> > without the slightest thought, is this not already done with Harbour?
> >
> > Many thanks in advice!
> >
> > PS: I have seen that it can be made into an exe, as the screenshot
> showing
> > a Hello World working made it clear, yet the advice on "how to compile"
> only
> > lists Linux as a simple guide. *sad face*
> >
> > --
> > smu johnson <smujohnson at gmail.com>
> > _______________________________________________
> > Harbour-users mailing list (attachment size limit: 40KB)
> > Harbour-users at harbour-project.org
> > http://lists.harbour-project.org/mailman/listinfo/harbour-users
> >
>
>
>
> --
> Massimo Belgrano
>
> Iscritto all'albo dei CTU presso il Tribunale di Novara per materia
> Informatica
> Delta Informatica S.r.l. (http://www.deltain.it/) (+39 0321 455962)
> Analisi e sviluppo software per Lan e Web - Consulenza informatica -
> Formazione
> _______________________________________________
> Harbour-users mailing list (attachment size limit: 40KB)
> Harbour-users at harbour-project.org
> http://lists.harbour-project.org/mailman/listinfo/harbour-users
>
--
smu johnson <smujohnson at gmail.com>
More information about the Harbour-users
mailing list