Static compilation - BASE/1302 Argument error:
Closed this issue · 3 comments
I am having a problem with static compilation.
Platform: Linux (Debian)
Compiler: gcc version 8.3.0 (Debian 8.3.0-6)
I want to compile my application (myapp.prg) including the Harbour static libraries. So that I can transfer the application to other machines without including the dynamic library harbour.so.
Recompiled Harbor core code with HB_USER_CFLAGS=-DHB_DYNLIB
I use to compile:
hbmk2 myapp.prg -n -es2 -static -strip
btw. it generates:
gcc 'myapp.o' -Wl,--start-group -lhbextern -lhbdebug -lhbvm -lhbrtl -lhblang -lhbcpage -lgtcgi -lgtpca -lgtstd -lgttrm -lhbrdd -lhbuddall -lhbusrrdd -lrddntx -lrddcdx -lrddnsx -lrddfpt -lhbrdd -lhbhsx -lhbsix -lhbmacro -lhbcplr -lhbpp -lhbcommon -lm -ldl -lrt -lpcre -lz -lgpm -Wl,--end-group -s -o'myapp'
(The problem I describe also occurs when I use "clean" harbor to compile)
The program compiles fine, the libraries are included (the size of the executable increases)
However, when I execute the program, functions like HB_CDPSELECT()
, DBUSEAREA()
give the error: "BASE/1302 Argument error:".
They seem to expect numeric arguments, not text strings.
When I compile the program with the dynamic harbour.so library, the problem does not occur. But when I want to move it to another machine I have to install Harbor library on it
Examples from my program generating an error:
hb_cdpSelect('PL852')
dbUseArea(.T.,DBF_DRIVER,"inwp.dbf","dbInwPoz",.T.,.N.)
Standard Clipper commands seem to work normally.
What am I doing wrong? What don't I know? I've read a lot of Harbor information and haven't encountered this problem.``
Damian Sz.
Static compilation should be straightforward, as long as you have those
REQUEST DBFCDX
REQUEST HB_CODEPAGE_PL852
etc...
in your app code.
I don't get the purpose of
HB_USER_CFLAGS=-DHB_DYNLIB
too
Thank you for your response. I think your answer will be useful for beginners. I've wasted some time finding the answer as it's not explicitly stated anywhere.
I read about the need to use the "DHB_DYNLIB" flag for core Harbor compilation in "Harbour for beginners" in the "How to use dynamic libraries ( dll, so )" section.
Sorry for my English, I use translator.
Best regards
On linux default is dynamic
On harbour creation:
SET HB_BUILD_DYN=no
SET HB_BUILD_CONTRIB_DYN=no
On projets or PRGS add flag
-static
But if you use functions using macro, functions are not linked.
Ex: &( "AnyFunction()" )
On this case, add REQUEST AnyFunction
Note:
I do not use linux, I made only single tests using ubuntu on windows long time ago.
May be anything change on this use.
On that time, dynamic harbour do not create static application
Make your own tests and confirm this