Is compiler possible portable ?

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
huangchenmin
Posts: 157
Joined: Mon Jun 07, 2010 2:24 am

Is compiler possible portable ?

Post by huangchenmin »

:lol: Hi every :D
I couldn't use specified pc exculsively, therefor I need a portable compiler in usb disk.
Is that possible? How should I do for that?
Best Regards
chen min
User avatar
cdsaenz
Posts: 58
Joined: Sun Jul 11, 2010 4:02 am

Re: Is compiler possible portable ?

Post by cdsaenz »

As far as I know HMG.4 is fully portable, shouldn't be writing anything in the registry (you only have to locate the QT* runtime libraries in the path for execution) and I saw that build.bat is using relative paths. I think HMG3.x's paths may need some touch-up to make it work from a drive different than C: but maybe the more experienced guys can confirm. In short, try putting the HMG folder in your thumb drive and see how it goes.
Charly
Argentina, Hobbyist developer, Clipper/Delphi/PHP/Progress
huangchenmin
Posts: 157
Joined: Mon Jun 07, 2010 2:24 am

Re: Is compiler possible portable ?

Post by huangchenmin »

cdsaenz wrote:As far as I know HMG.4 is fully portable, shouldn't be writing anything in the registry (you only have to locate the QT* runtime libraries in the path for execution) and I saw that build.bat is using relative paths. I think HMG3.x's paths may need some touch-up to make it work from a drive different than C: but maybe the more experienced guys can confirm. In short, try putting the HMG folder in your thumb drive and see how it goes.
Dear cdsaenz:
Thanks for your reply.
3.0.34 is the version I using now. According to you described, What I should do is copy all files included in c:\HMG.3.0.34\ and change the path, in which the libraries link to. Then see if it is done or not! Is that right!
Beset Regards
chen min
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: Is compiler possible portable ?

Post by l3whmg »

Hello,
I hope I have understood your question my answer is yes and then I'll show you what I use

Some preliminary clarifications:
1 - I am referring to version 3 and not 4 which is under development
2 - I install the distribution of HMG as it is, in the same folder on a partition other than C and obviously I lose the previous version.
3 - I use the files with extension HBC and HBP. In particular, the first file allows you to add "include files and libraries" without altering the compile command.
4 - I modified the build.bat command standards according to my needs, you'll notice that it has fewer options.

Pay attention to certain elements:
A) I do not use the redir command because with (my) WinXp Sp3 this control is already operational, in fact I use the notation "2> & 1".
B) line

Code: Select all

SET HmgPath=D:\HMG\MiniGui
where you set the directory where you installed HMG
C) the line

Code: Select all

SET PATH=%HmgPath%\util;%HmgPath%\mingw\bin;%HmgPath%\harbour\bin;
where you declare the route where MsWin find commands about HMG
D) about resources, thanks to _hmg_resconfig.h file, where with HMGRPATH variable you declare the directory where are the resources (Attention line

Code: Select all

SET Resources=_temp.o
where the previous value is reset). Obviously, you can add other local .rc file, with the same name as the source to compile.
E) if the executable is generated, will be placed in the same directory where the source resides.

Occurs well before using it to control and adapt for your needs, referring to the standard command "build.bat" for more options to activate.

This is my command

Code: Select all

@ECHO OFF
CLS

REM ****************************************************************************
REM batch file to compile programs with HarbourMinigui
REM ****************************************************************************
SET IntError=0

REM ****************************************************************************
REM Set HMG environment and compiler environment
REM ****************************************************************************
SET HmgPath=D:\HMG\MiniGui
SET HmgVer=""
SET /p HmgVer=<%HmgPath%\version.txt
SET Resources=%HmgPath%\resources\hmg.o
SET GT=-gtgui
SET DEBUG=""
SET BUILDTYPE=""
SET REBUILDALL=""
SET MT=

REM ****************************************************************************
REM preserve PATH value and add HMG path
REM ****************************************************************************
SET Tpath=%PATH%
SET PATH=%HmgPath%\util;%HmgPath%\mingw\bin;%HmgPath%\harbour\bin;

REM ****************************************************************************
REM repeat params check
REM ****************************************************************************
:elabparms

REM ***************************************************************************
REM syntax help
REM ***************************************************************************
IF "%1"=="?" GOTO syntax
IF "%1"=="-h" GOTO syntax
IF "%1"=="/h" GOTO syntax

REM ***************************************************************************
REM go to compilers section
REM ***************************************************************************
GOTO befcheck

REM ***************************************************************************
REM Syntax
REM ***************************************************************************
:syntax
ECHO :: Syntax:
ECHO ::
ECHO :: "nbuild <PrgFile> | <filelist.hbp> [config.hbc]"
ECHO ::
ECHO :: filelist.hbm : A text file with .hbp extension containing a source list
ECHO :: configfile.hbc: A text file with configuration parameters as additional
ECHO :: libs, include paths and lib paths.
ECHO ::
ECHO :: configfile.hbc Syntax:
ECHO ::
ECHO :: incpaths = incpath1 incpath2 ... incpathn
ECHO :: libpaths = libpath1 libpath2 ... libpathn
ECHO :: libs = lib1 lib2 ... libn
ECHO ::
ECHO :: library names must not include 'lib' prefix nor '.a' extension.
ECHO :: build.bat will create an 'error.log' file in the app folder when build
ECHO :: process ends with an error condition.
ECHO :: <.hbc> files in the current folder are automatically processed.
PAUSE
GOTO cleanup

REM ****************************************************************************
REM start
REM ****************************************************************************
:befcheck
IF EXIST %~n1.exe DEL %~n1.exe
IF EXIST %~n1.exe GOTO error00
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 %~n1.hbp GOTO cmpres
IF EXIST %~n1.prg GOTO cmpres
GOTO error01

REM ***************************************************************************
REM resource compile
REM ***************************************************************************
:cmpres
IF NOT EXIST %~n1.rc GOTO cmpprg
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
SET Resources=_temp.o

REM ***************************************************************************
REM .prg | .hbp compile
REM ***************************************************************************
:cmpprg
hbmk2 -o%~n1.exe %GT% %DEBUG% %MT% %BUILDTYPE% %REBUILDALL% -incpath=%HmgPath%\include -L%HmgPath%\lib -lhmg -lhbmysql -lmysql -lcrypt -ledit -leditex -lgraph -lini -lreport -lhbwin -lhbziparc -lhbmzip -lmsvfw32 -lvfw32 -lsddodbc -lrddsql -lsddmy -lhbodbc -lodbc32 -lhbhpdf -lhbvpdf -lhbmemio -lhbsqlit3 -lsqlite3 -lhbfimage -lhbpgsql -lpq -lhbtip -lhbct -lhbmisc -lhbnetio -lxhb -prgflag=/q -cflag=-O3 %1 %2 %3 %4 %5 %6 %7 %8 %9 %Resources%  >hbmk.log 2>&1
IF ERRORLEVEL 1 GOTO error04
GOTO cleanup

REM ***************************************************************************
REM errors
REM ***************************************************************************
:error00
CLS
ECHO Can't remove %~n1.exe
SET IntError=1
GOTO cleanup

:error01
CLS
ECHO Can't find %~n1
SET IntError=1
GOTO cleanup

:error03
CLS
ECHO Resource compiler error
SET IntError=1
GOTO cleanup

:error04
CLS
ECHO Source compiler error
SET IntError=1
GOTO cleanup

REM ***************************************************************************
REM end and clean
REM ***************************************************************************
:cleanup
IF EXIST _hmg_resconfig.h DEL _hmg_resconfig.h
IF EXIST _temp.rc DEL _temp.rc
IF EXIST _temp.o  DEL _temp.o
IF EXIST *.o DEL *.o
IF EXIST *.c DEL *.c

SET PATH=%Tpath%
SET HmgPath=
SET HmgVer=
SET Resources=
SET GT=
SET DEBUG=
SET BUILDTYPE=
SET REBUILDALL=
SET MT=
SET L3wSys=

REM ***************************************************************************
REM if is there one error dont' delete log files
REM ***************************************************************************
IF %IntError%==1 GOTO nodel
IF EXIST windres.log DEL windres.log
IF EXIST hbmk.log DEL hbmk.log
:nodel
SET IntError=

REM ***************************************************************************
REM end
REM ***************************************************************************
:end

I hope to have been helpful
Luigi from Italy
www.L3W.it
Post Reply