понедельник, 9 марта 2009 г.

В предыдущем посте сказано, как собирать Харобор из исходников через SVN. Но, как всегда в Линуксе - есть альтернативный путь - просто скачать, распаковать и запустить скрипт сборки.

распаковать в /usr/src/harbour

cd /usr/src/harbour

make_gnu.sh all
make_gnu.sh install

вот, как-то так...

Не забываем, что нужны хидеры Иксов!!!

apt-get install xorg-dev

Мне еще пришлось создать пару папочек

sudo mkdir /usr/local/lib/harbour
sudo mkdir /usr/local/include/harbour

только после этого шаманства инсталляция закончилась

Итак, будем считать, что Харбор собран и установлен. самая простая проверка - запустить сам компилятор:
--------------------------------------------------
dimao@dimao-desktop:~$ harbour
Harbour 1.1.0dev (Rev. 10272)
Copyright (c) 1999-2009, http://www.harbour-project.org/

Syntax: harbour [options]

Options: -a automatic memvar declaration
-b debug info
-build display detailed version info
-credits display credits
-d[=] #define
-es[] set exit severity
-fn[:[l|u]|-] set filename casing (l=lower u=upper)
-fd[:[l|u]|-] set directory casing (l=lower u=upper)
-fp[:] set path separator
-fs[-] turn filename space trimming on or off (default)
-g output type generated is (see below)
-gc[] output type: C source (.c) (default)
: 0=compact (default) 1=normal 2=verbose
3=generate real C code
-go output type: Platform dependant object module
-gh output type: Harbour Portable Object (.hrb)
-i #include file search path
-j[] generate i18n gettext file (.pot)
-k compilation mode (type -k? for more data)
-l suppress line number information
-m compile module only
-n[] no implicit starting procedure (default)
: 0=no implicit starting procedure
1=no starting procedure at all
-o object file drive and/or path
-p[] generate pre-processed output (.ppo) file
-p+ generate pre-processor trace (.ppt) file
-q quiet
-q0 quiet and don't display program header
-r: set maximum number of preprocessor iterations
-s syntax check only
-u[] use command def set in (or none)
-undef: #undef
-v variables are assumed M->
-w[] set warning level number (0..3, default 1)
-x[] set symbol init function name prefix (for .c only)
-z suppress shortcutting (.and. & .or.)
@ compile list of modules in
dimao@dimao-desktop:~$
------------------------------------------
ну вот и все - можно компилировать программы. На сайте проекта можно найти простенький "ХауТу".

-------------------------------------------
http://www.harbour-project.org/samples/HowToBuildOnLinux.html
-------------------------------------------

How to Build on Linux


In the last phase of install process if bash shell is available in the system then few bash scripts are created to make compiling and linking with Harbour a little easier. There are compiler and linker wrappers called "hbcc", "hbcmp", "hblnk" and "hbmk".

"hbcc" is a wrapper to the C compiler only. It sets all flags and paths necessary to compile .c files which include Harbour header files. The result of its work is an object file.

Use "hbcmp" exactly as you would use the harbour compiler itself. The main difference with hbcmp is that it results in an object file, not a C file that needs compiling down to an object. hbcmp also ensures that the harbour include directory is seen by the harbour compiler.

"hblnk" simply takes a list of object files and links them together with the harbour virtual machine and run-time library to produce an executable. The executable will be given the basename of the first object file if not directly set by the "-o" command line switch.

"hbmk" tries to produce an executable from your .prg file. It's a simple equivalent of cl.bat from the CA-Clipper distribution.

All these scripts accept command line switches:
-o # output file name
-static # link with static Harbour libs
-fullstatic # link with all static libs
-shared # link with shared libs (default)
-mt # link with multi-thread libs
-gt # link with GT driver, can be repeated to
# link with more GTs. The first one will be
# the default at runtime
-xbgtk # link with xbgtk library (xBase GTK+ interface)
-hwgui # link with HWGUI library (GTK+ interface)
-l # link with library
-L # additional path to search for libraries
-fmstat # link with the memory statistics lib
-nofmstat # do not link with the memory statistics lib (default)
-[no]strip # strip (no strip) binaries
-main= # set the name of main program function/procedure.
# if not set then 'MAIN' is used or if it doesn't
# exist the name of first public function/procedure
# in first linked object module (link)

Link options work only with "hblnk" and "hbmk" and have no effect in "hbcc" and "hbcmp". Other options are passed to Harbour/C compiler/linker.
An example compile/link session looks like:
---------------------------------------------------------------------------------------
druzus@uran:~/tmp$ cat foo.prg
function main()
? "Hello, World!"
return nil

druzus@uran:~/tmp$ hbcmp foo
Harbour Compiler Alpha build 46.2 (Flex)
Copyright 1999-2006, http://www.harbour-project.org/
Compiling 'foo.prg'...
Lines 5, Functions/Procedures 2
Generating C source output to 'foo.c'... Done.

druzus@uran:~/tmp$ hblnk foo.o
druzus@uran:~/tmp$ strip foo
druzus@uran:~/tmp$ ls -l foo
-rwxrwxr-x 1 druzus druzus 3824 maj 17 02:46 foo
---------------------------------------------------------------------------------------

or using hbmk only:
---------------------------------------------------------------------------------------
druzus@uran:~/tmp$ cat foo.prg
function main()
? "Hello, World!"
return nil

druzus@uran:~/tmp$ hbmk foo
Harbour Compiler Alpha build 46.2 (Flex)
Copyright 1999-2006, http://www.harbour-project.org/
Compiling 'foo.prg'...
Lines 5, Functions/Procedures 2
Generating C source output to 'foo.c'... Done.

druzus@uran:~/tmp$ ls -l foo
-rwxrwxr-x 1 druzus druzus 3824 maj 17 02:46 foo
---------------------------------------------------------------------------------------

You will find additional wonderful tools: /usr/bin/hbrun
You can run clipper/xbase compatible source files with it if you only put in their first line: #!/usr/bin/hbrun

For example:
----------------------------------------------------------------------
druzus@uran:~/tmp$ cat foo.prg
#!/usr/bin/hbrun
function main()
? "Hello, World!, This is a script !!! :-)"
return nil

druzus@uran:~/tmp$ chmod +x foo.prg
druzus@uran:~/tmp$ ./foo.prg

Hello, World!, This is a script !!! :-)

druzus@uran:~/tmp$

I hope you will find this information useful,
Przemyslaw Czerpak (druzus/at/priv.onet.pl)

Комментариев нет: