Lib File

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
Tristan
Posts: 40
Joined: Sun Jul 19, 2009 2:15 pm

Lib File

Post by Tristan »

Hi :D

I need some help. How to make lib file with harbour?

Thanks & Regards,
Tristan
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: Lib File

Post by l3whmg »

Hi Tristan,
with HBMK2 you must use -hblib (this option tell to Harbour: create a lib). Obviously, you must use -o"libname".
I suggest to you to use -w3 and -es2. You can use -inc (incremental). This params can be used within a batch command or within your *.hbp file.
This is a hbp example

Code: Select all

-hblib
-inc
-ol3wlib
-w3 -es2
source1.prg
source2.prg
To create lib HBMK2 example.hbp -trace > logfile 2>&1

Please, take a look to the HMG folder and command or official Harbour site or ie here http://harbourlanguage.blogspot.com/201 ... hbmk2.html

Cheers
Luigi from Italy
www.L3W.it
User avatar
danielmaximiliano
Posts: 2611
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: Lib File

Post by danielmaximiliano »

Hola Tristan/Luigi:
en C:\hb31\examples\hbvpdf hay un ejemplo como compilar una libreria de Harbour
  • hbvpdf.ch
    hbvpdf.hbc
    hbvpdf.hbp
    hbvpdf.prg
    hbvpdft.prg
    hbvpsup.prg
    readme.txt
    <DIR> tests
desde la consola CMD ejecutar solo el comando HBMK2 hbvpdf.hbp que contiene

Code: Select all

#
# $Id: hbvpdf.hbp 16868 2011-06-07 22:29:10Z vszakats $
#
-hblib
-inc
-olib/${hb_plat}/${hb_comp}/${hb_name}
-w3 -es2

-instfile=inc:hbvpdf.ch

hbvpdf.prg
hbvpdft.prg
hbvpsup.prg
hbvpdf.hbc contiene la ruta de la carpeta de librerias

Code: Select all

#
# $Id: hbvpdf.hbc 14687 2010-06-04 11:08:35Z vszakats $
#
incpaths=.
libpaths=lib/${hb_plat}/${hb_comp}
libs=${hb_name}
en este caso las variables ${hb_plat} se refiere a la plataforma de instalacion
y ${hb_comp} el compilador a ejecutar
puedes usar este pequeño BATCH para simplificar le creracion de las librerias ya que es engorroso moverse dentro de la consola CMD.

Code: Select all

@echo off
@echo  
if "%1"=="" goto Input
rem   %* es toda la linea de parametros pasados a createlib.bat
rem  %1 %2 %3 %4 %5 %6 %7 %8 %9
rem    
c:\hb31\bin\hbmk2  %*
goto Finish

:Input
@cls
@echo *******************************************************************************
@echo SYNTAX
@echo *******************************************************************************
@echo   "Build [ /n ] [ /d ] [ /c ] <program.prg>"
@echo   "              or                        "
@echo   "Build <project.hbp> [<hbmk2 params>]    "
@echo.
@echo   /n	no run after build
@echo   /d	enabled debugger
@echo   /c	console mode
@echo.
@echo.
@echo   This batch file passes information to hbmk2 to make possible an easy (zero
@echo   configuration build of HMG applications).
@echo.
@echo   You can achieve a customized build passing parameters directly to hbmk2.
@echo   Please, take a look at hbmk2 help:
@echo.
@echo   hbmk2 --help
@echo.
@echo ********************************************************************************
@echo.
@echo Enter LIB name to compile, Extension .hbp assume if it exists
@Set /p Libname=  Input lib name :
@if EXIST %Libname%.hbp Goto HBP 
@if EXIST %Libname%.prg Goto PRG
@echo.
@echo 
@echo File %Libname% Not Exist
@echo Press any key for Continue
@pause > nul
@goto Input

:HBP
@Echo Compile %Libname%.hbp
c:\hb31\bin\hbmk2  %libname%.hbp 
goto Input

:PRG
Puedes llamarlo CreateLib.bat y lo pegas donde quieras.
PD: puede ser que la ruta de HBMK2 sea distinta en tu instalacion
C:\hb31\bin
C:\HMG3.0.38\HARBOUR\bin
C:\hmg.4\HARBOUR\bin
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: Lib File

Post by l3whmg »

Hi Daniel,
many thanks for your explanation about "hb_" var.

On the other hand, very interesting because a lot of HMG users have problem to find hbvpdf lib (see other post about HMG 3.0.38) and, as I write in the same post, I suggest to see within harbour examples folder :lol:

Best regards
Luigi from Italy
www.L3W.it
User avatar
danielmaximiliano
Posts: 2611
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: Lib File

Post by danielmaximiliano »

l3whmg wrote:Hi Daniel,
I suggest to see within harbour examples folder :lol:
Hi Luigi :
mi aplicacion esta en C:\SEGUROS and C:\Vencimientos
desde la linea de comando build.bat y buildapp.bat no funciona.
por eso la modificacion de Build.bat agregando rutas estaticas como C:\HMG3.0.38
sino pruebe este ejemplo de buildapp.bat , si lo ejecuta dentro de C:\ o D:\ vera que no funciona %~dp0 como cero configuracion.

my application is in C:\SEGUROS and C:\Vencimientos
from the command line buildapp.bat and build.bat does not work.
so the modification of Build.bat adding static routes as C:\HMG3.0.38
but try this buildapp.bat example, if you run it in C:\ or D:\ does not work %~dp0 as zero configuration.

Code: Select all

@echo off

rem *******************************************************************************
rem SYNTAX
rem *******************************************************************************
rem	build [ /n ] [ /d ] [ /c ] <program.prg> | <project.hbp> [<hbmk2 params>]
rem
rem	/n	no run after build
rem	/d	enabled debugger
rem	/c	console mode
rem
rem
rem	This batch file passes information to hbmk2 to make possible an easy (zero
rem	configuration build of HMG applications).
rem 
rem	You can achieve a customized build passing parameters directly to hbmk2.
rem	Please, take a look at hbmk2 help:
rem
rem	hbmk2 --help

rem *******************************************************************************
rem SET DEFAULT OPTIONS
rem *******************************************************************************

	set gtdrivers=-gtgui -gtwin
	set runafterbuild=.t.
	set debug=

rem ******************************************************************************
rem DELETE FILES FROM PREVIOUS BUILD
rem ******************************************************************************

	if exist build.log del build.log
	if exist error.log del error.log

rem ******************************************************************************
rem SET HMGPATH
rem ******************************************************************************
rem
rem Using %~dp0 the HMGPATH is automatically set to current (hmg) folder making it
rem portable (zero config)

	SET HMGPATH=%~dp0
echo %~dp0%
echo %hmgpath%
pause
rem ******************************************************************************
rem SET BINARIES PATHS
rem ******************************************************************************

	SET PATH=%HMGPATH%\harbour\bin;%HMGPATH%\mingw\bin;%PATH%

rem *******************************************************************************
rem PROCESS PARAMETERS 
rem *******************************************************************************
rem
rem	/n	no run after build
rem	/d	enabled debugger
rem	/c	console mode
rem

	if "%1"=="/n" set runafterbuild=.f.
	if "%1"=="/n" shift

	if "%1"=="/d" set gtdrivers=-gtwin -gtgui
	if "%1"=="/d" set debug=-b
	if "%1"=="/d" echo options norunatstartup > init.cld
	if "%1"=="/d" shift

	if "%1"=="/c" set gtdrivers=-gtwin -gtgui
	if "%1"=="/c" shift

rem ******************************************************************************
rem COMPILE RESOURCES
rem ******************************************************************************

	echo #define HMGRPATH %HmgPath%\RESOURCES > _hmg_resconfig.h
	COPY /b %HMGPATH%\resources\hmg.rc+%~n1.rc+%HMGPATH%\resources\filler _temp.rc >NUL
	windres -i _temp.rc -o _temp.o >windres.log 2>&1

rem *******************************************************************************
rem SET PROJECT OUTPUT FILE NAME 
rem *******************************************************************************
rem
rem The first parameter sent to hbmk2 is -o%~n1.exe. I've added to it create the 
rem application with the project basename (<projectname.hbp> specified by the user.

rem *******************************************************************************
rem SET DEFAULT CONFIGURATION FILE
rem *******************************************************************************
rem
rem The second parameter sent to hbmk2 is the hmg.hbc script to set config required.

rem *******************************************************************************
rem SET QUIET MODE
rem *******************************************************************************
rem
rem The third parameter sent to hbmk2 is -q (Harbour quiet mode)

rem ******************************************************************************
rem CALL HBMK2
rem ******************************************************************************

	HBMK2 -o%~n1.exe %HMGPATH%\hmg.hbc %gtdrivers% %debug% -q %1 %2 %3 %4 %5 %6 %7 %8 >hbmk.log 2>&1

rem ******************************************************************************
rem CREATE LOGS
rem ******************************************************************************

	if errorlevel 1 if exist windres.log copy /a windres.log+hbmk.log error.log >nul
	if errorlevel 1 if not exist windres.log copy /a hbmk.log error.log >nul

	if errorlevel 0 if exist windres.log copy /a windres.log+hbmk.log build.log >nul
	if errorlevel 0 if not exist windres.log copy /a hbmk.log build.log >nul

rem ******************************************************************************
rem CLEANUP
rem ******************************************************************************

	if exist windres.log del windres.log
	if exist hbmk.log del hbmk.log
	if exist _hmg_resconfig.h del _hmg_resconfig.h
	if exist _temp.rc del _temp.rc
	if exist _temp.o  del _temp.o

rem ******************************************************************************
rem SHOW LOG
rem ******************************************************************************

	if exist error.log type error.log
	if exist build.log type build.log

rem ******************************************************************************
rem RUN APPLICATION
rem ******************************************************************************

	if "%runafterbuild%"==".t." if exist %~n1.exe %~n1.exe
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: Lib File

Post by l3whmg »

Hi Daniel,
you are right. For this reason I write (in other post) that I need to change build.bat and buildlib.bat.
This is my modified buildlib.bat about HMG

Code: Select all

@echo off
REM
REM $Id: buildlib.bat 438 2010-10-19 02:37:12Z roblez $
REM
SET HB_COMPILER=mingw
SET SAVPATH=%PATH%
SET HRBHOME=D:\HMiniGui\HARBOUR
SET HRBBIN=%HRBHOME%\bin
SET MGWHOME=%HRBHOME%\comp\mingw
SET MGWBIN=%MGWHOME%\bin
SET HMGPATH=%~dp0
rem this was the original row that I remarks SET PATH=%HMGPATH%\harbour\bin;%HMGPATH%\mingw\bin;%PATH%
SET PATH=%HRBBIN%;%MGWBIN%;%PATH%

hbmk2 hmg.hbp > hbmk.log 2>&1

SET PATH=%SAVPATH%
SET HB_COMPILER=
SET HRBHOME=
SET HRBBIN=
SET MGWHOME=
SET MGWBIN=
SET HMGPATH=
SET SAVPATH=
First difference: in this way the current value of PATH is preserved with SAVPAT and, at the end, restored. In this way your current environment is preserved else is "update" every time you run buildlib.bat
Second difference: I don't use (normally) Harbour/Mingw distribuited with HMG, so I need to point Harbour compiler and MinGw linker (see HRBHOME, HRBBIN, MGWHOME and MGWBIN ). HMGPATH is unusefull here but within build.bat yes because there are resources file.
Third difference: as you write: "my project and libs are located in a very difference folder" than HMG. I'm in agreement with you, because a) I want to keep clear and original HMG folders, b) I don't want to mix my project (source/bin) with HMG c) I want to prevent deleting file (when I download HMG, I must update its folder and, if there are other files, I can have the risk to delete my files).
Fourth: I can use only one Harbour/MinGw distribution to compile HMG3 and HMG4 projects (when possible, actually there are some problem with Harbour 3.1 and HMG3.0.38).
Fifth but this is my opinion: I think the installer must only create/copy within destination folder (C:\HMG or D:\HMG or E:\MiniGui\SomeOther\HMG, as I prefer). Why? I dont' want that the installer create folders within c:\windows folders.

As you can read here (and about me in other post) we are in agreement.
I don't know how other HMG users have installed pakcages and works, but I suggest many times to pay attention at this folder situation:
<drive>:\Myprojects\<ubfolders>
<drive>:\HMG\<subfolders>
<drive>:\HARBOUR\<subfolders>
and if someone want it
<drive>:\MINGW\<subfolders>
and check buildlib.bat and build.bat commands with many resources file (not only hmg.rc)

Cheers
Luigi from Italy
www.L3W.it
User avatar
danielmaximiliano
Posts: 2611
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: Lib File

Post by danielmaximiliano »

Hola Luigi:
no he utilizado Harbour al nivel que tu programas.
pero HMG se mantiene simplista oara un usuario comun sin necesitar de la distribucion Harbour.
mi necesidad de modificar Build.bat es que el mismo falla al hacer doble click en el mismo e intenta compilar una aplicacion que no existe.
el nuevo modo pide un nombre de archivo y por defecto asume .HBP y despues asume .PRG , si el mismo se ejecuta desde la linea de comando el mismo llama a Buildapp que esta 2 niveles por debajo call ..\..\build.bat %*
sabemos que HMG es una Envoltura y que posiblemente Harbour este atrasado con respecto al Proyecto Harbour.
esto involucra que no se pueda usar algunas caracteristicas nuevas y estemos atados a Harbour / Minigui dentro de HMG.
para ud. creo necesario una pequeña aplicacion que si no es pasado el nombre del proyecto o nombre de la aplicacion PRG, poder con cajas de chequeo agregar librerias y RDD. tambien elegir el compilador original o uno mas actual, tal cual lo hace los demas IDEs.
voy a ver si se puede modificar Build.bat para incluir las librerias he includes del proyecto Harbour que son mas completas.


Hello Luigi:
Harbour have not used your program level.
but remains simplistic HMG oara a common user without requiring the distribution Harbour.
Build.bat my need to change is that it fails when you double-click it and try to compile an application that does not exist.
the new way calls for a file name and by default assumes. HBP and then assumed. PRG, if it is run from the command line the same calls BuildApp that levels below 2 call .. \ .. \ build. bat% *
know that HMG is a wrap and possibly Harbour being delayed with respect to the Harbour Project.
this involves not be able to use some new features and we are bound to Harbour / Minigui within HMG.
for you. I need a small application that if it is passed the name of the project or application name of the PRG, with check boxes to add libraries and RDD. also choose the original compiler or a more current as it does the other IDEs.
I'll see if can be modified Build.bat to include the libraries, includes project Harbour that are more complete.
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
danielmaximiliano
Posts: 2611
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: Lib File

Post by danielmaximiliano »

Hi Luigi:
See news post in Harbour User

http://groups.google.com/group/harbour- ... 58d89cd9d4
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: Lib File

Post by l3whmg »

Hi Daniel.
I'm sorry but I don't understand very well your previous post and the last one imho treats another/different problem.

The batch files are the more simple way to compile and link: in *nix and M$. We can have a GUI program to replicate these commands (to include default libraries, include files, resources and other), but at the end a (or more) "batch command" (please give me one cent for this) must be called. Hbmk2 has problems in some conditions usage? I don't know and I can't answer. Someone wants use different version of MinGw and they have problems? Mmmmh, Why they want use it?

I have developed XBase programs from HMG 1 and now with HMG 3.0.35 (Hrb/MinW distribuited with Hmg). When I understand something, I started to download and use official Harbour (before without MinGw, but now with internal version). For this reason, it's a long time that I have some problems during compilation and I solved them with "batch commands" customized, now adding .hbp and .hbc files.

HMG3 (next generation) needs to use the last version of Harbour otherwise is out of date (HMG4 can work fine becasue - at this moment - use standard Harbour/MinGw libraries). I write about problem between Harbour 3.1 and HMG 3.0.38 because "with my architecture" I find the incompatibility. Why? Because I'm using a centralized installation of Harbour for HMG3 (next generation) and HMG4 (but I dont' use it for the previous HMG3).

HMG3 (next generation) and HMG4 must be compiled and used with current Harbour distribution; for this reason, these HMG versions must respect Harbour philosophy, libraries, etc. We must create "batch commands" very simples: a) to show how a program can be compiled and linked with HMG (I was/am a beginner), b) every one can use different architecture. More simple and clear, more people can understand. A GUI program to compile and link? Yes, it's very good, but attention: imho, for a beginner can be too many easy ... to do a mistake or to loose something without a clear idea!

So, I don't understand your last posts. I hope to have clarify my pow and suggestions. Anyway, thanks a lot of all.

Luigi
Luigi from Italy
www.L3W.it
Post Reply