Harbour on Linux question

395 views
Skip to first unread message

cod...@outlook.com

unread,
Oct 10, 2020, 2:34:33 PM10/10/20
to Harbour Users

I always used Windows to work with Clipper and Harbour.

For some reasons I must jump in Harbour on Linux. These days I have installed Ubuntu Server 20.04, and somehow I succeeded. Up to now I login only with user I defined in installation process, so I think that it is root user, or it is not ?

Then I found on internet how to install Harbour from git sources. I used this link:

https://harbour.wiki/index.asp?Session=193558196628227415&page=PublicArticles&mode=show&id=191217205049&sig=1012240743#section_8753775549

And full list of dependencies  I found on this link:

https://ubuntuforums.org/showthread.php?t=2035652

According to first link I placed Harbour sources under /opt/TuxPrograms/trunks  directory. Whole installation process of Harbour succeeded.

After that I created /data folder, just under  /  (root) directory. In that folder I copied some file TEST.DBF. I must say that all commands I typed with sudo ... up to now I do not know how to create another ordinary (non super) user. Then in same directory I made test.prg:

CLS

?"FILE = ",FILE("TEST.DBF")

?"CURDIR = ",CURDIR()

USE TEST

QUIT

 

At the end I used hbmk2:

sudo hbmk2 test.prg    // commands do not work without sudo ...

Compilation successfully finished, no errors. At the end I started test with:

./test          (also tried with sudo ./test, same errors)

As a result on tty screen I got:

FILE = .T.

CURDIR = data

DBFNTX/1001 Open error TEST.dbf (DOS Error 2)

 

All is logical except in USE command !? Here I stopped. I do not know what to do. I read many threads but did not find this particular situation.  I tried with sudo chmod –R 755 /data, but no success.

Please if someone can advice me what to do.

-Why this happened ?

-Is there are better place for Harbour ? Some people says that it is better to place it in /usr/local directory.

-I will appreciate if you can give me some other advices on how to work with Harbour on Linux, where to place Harbour, where to place PRGs, where to place DBFs.

Thank you in advance.

 

Best Regards,

Simo. 

jgt

unread,
Oct 10, 2020, 3:25:36 PM10/10/20
to Harbour Users
The user that you created on installation is the owner, and has similar permissions to root, but is not root.
It is preferable not to place data files in the root file system. Create a secondary file system for applications and data.
To begin with, set all data files (.dbf, .idx, .ntx, .cdx, etc) to 0666 (read write by all). Set directories to 0777 so that users can create new  or temporary data files.  You can fine tune this when as you get a better feel for Linux.
Create another user to do testing.
Move hbmk2 and hbrun to /usr/local/bin if users can compile programs and have "dot prompt" access to data.
I usually use the following directory structure:
/u/myapp/
                   src
                  exe
                 dbf
                 idx
                tmp
                input
                output
               work
                ksh (or bash)
Also Linux file names are case sensitive.  TEST.dbf and test.dbf are not the same file. 
 

Alain Aupeix

unread,
Oct 10, 2020, 4:12:13 PM10/10/20
to harbou...@googlegroups.com, jgt


Le 10/10/2020 à 21:25, jgt a écrit :
The user that you created on installation is the owner, and has similar permissions to root, but is not root.
It is preferable not to place data files in the root file system. Create a secondary file system for applications and data.
Application can be located in a root folder, no problem

To begin with, set all data files (.dbf, .idx, .ntx, .cdx, etc) to 0666 (read write by all). Set directories to 0777 so that users can create new  or temporary data files.
Sure, but perhaps change owner of th e folder with
sudo chown -R <user>:<user> <folder>


  You can fine tune this when as you get a better feel for Linux.
Sure :)

Create another user to do testing.
Before changing the owner

Move hbmk2 and hbrun to /usr/local/bin
If harbour is installed, these progs are already located here

if users can compile programs and have "dot prompt" access to data.
I usually use the following directory structure:
/u/myapp/
                   src
                  exe
                 dbf
                 idx
                tmp
                input
                output
               work
                ksh (or bash)
I'm not on a server, and I can't give a concil for that

Also Linux file names are case sensitive.  TEST.dbf and test.dbf are not the same file.
Obviously ...

A+
--

Alain Aupeix
Sites web : JujuLand | Pissobi-Lacassagne | Gadel
X.ubuntu 16.04 [ H.arbour 3.2.0dev (r2020-01-31 14:34) | Hw.gui 2.22-4-r2890 | G.ramps 5.1.2


cod...@outlook.com

unread,
Oct 11, 2020, 2:46:24 AM10/11/20
to Harbour Users
Thank you both for valuable suggestions !
I will answer what I did.
Best Regards,

Simo. 

cod...@outlook.com

unread,
Oct 11, 2020, 5:42:32 AM10/11/20
to Harbour Users

Hi.

In short, nothing changed.

USE TEST still gives DBFNTX/1001 Open error TEST.dbf (DOS Error 2).

Tried also with USE TEST READONLY. No changes.

FILE("TEST.DBF") gives .T.

In my example TEST.DBF is in upper case. I tried also with test.dbf, no changes.

I created /data/sdata directory and moved all files to that subfolder. In that sdata subfolder I have:

TEST.DBF

test.prg

test (executable, created after hbmk2 test.prg)

I set TEMP.DBF to 0666. I set directory data and data/sdata to 0777. Also changed ownership from root to user beta (beta is my user created in installation process).

I can't beleive that this simple example do not work !? All files are in one directory. No need to write only to read TEST.DBF.

Note: Harbour is 3.20dev (r2009190002). Hbmk2 and other progs are already in /usr/local/bin .

 

May be to switch from Ubuntu server to Ubuntu desktop ?

 

Best Regards,

Simo. 

Francesco Perillo

unread,
Oct 11, 2020, 6:01:01 AM10/11/20
to harbou...@googlegroups.com
try
use( "test.dbf" )
and be sure that all filenames are lowercase.

linux is linux... server or desktop is just a different set of programs installed and configured.

There are some settings (sorry, I can't remember) to let harbour change filenames' case during such operations.

I can only say that I have this code correctly working inside a program called every night with hbrun program.prg

procedure opendbf()

if ! file( "statbsp.dbf" )
...
   dbCreate( "statbsp.dbf", a )
endif

select 1
use statbsp
zap
index on ANNO+MESE+COMP to statbsp

select 2
use tkt
return

I have no special settings in the code, but of course, since it is invoked by hbrun, there may be some settings from it.
On the file system, everythin is lowercase.

-rw-rw-rw- 1 nobody nobody 58288263 Oct  9 15:59 tkt.dbf
-rw-rw-rw- 1 nobody nobody  7532544 Oct  9 15:53 tkt.ntx

-rw-rw-rw- 1 nobody nobody 193069 Oct 11 09:00 statbsp.dbf
-rw-rw-rw- 1 nobody nobody 345088 Oct 11 09:00 statbsp.ntx


--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-users/787e8ddb-dd25-44bb-8c81-4e57b68aa9bcn%40googlegroups.com.

Francesco Perillo

unread,
Oct 11, 2020, 6:21:20 AM10/11/20
to harbou...@googlegroups.com
Just to add that I have a samba server running on linux, all the clients are on windows. I created some tools/scripts to run directly on the server, when I connect remotely for example.

Anyway, I strongly suggest you get in touch with someone proficient in linux system administration and harbour specific requirements.


I once decided to see if it would be possible to get rid of samba and hide .dbfs away from the clients (ransomware anybody?) The program compiled and worked +or- ok. There are some places where files are opened in another directory and temp files created in c:\temp... all those should be changed.

So I cloned my repository and modified it. In 99% of cases, I use a function to open dbf files, and the change was really simple:
@@ -252,10 +252,10 @@
          // ENDIF
          IF ValType( ind ) = "A"
             for i = 1 TO Len( ind )
-               dbSetIndex( ind[i] )
+               dbSetIndex( lower( ind[i] ) )
             next
          ELSE
-            dbSetIndex( ind )
+            dbSetIndex( lower( ind ) )

Unfortunately I had a lot of #include to modify (yes, I could create a symbolic link or a placeholder file...)
-#include "Fileman.ch"
+#include "fileman.ch"

I don't remember if this was mandatory, but I have in the code:
-#include "..\tstair.ch"
+#include "../tstair.ch"


I also had to change the .hbp files in both ways (the source code has lower and upper case directory and file names... something that I should take care of but I'm probably going to break the repository...):
-procs\tgetlist.prg
-procs\flagbrow.prg
-procs\xls.prg
+PROCS\tgetlist.prg
+PROCS\flagbrow.prg
+PROCS\xls.prg
 -sa\SA.PRG
+sa\sa.prg

On Sun, Oct 11, 2020 at 11:42 AM cod...@outlook.com <cod...@outlook.com> wrote:
--

Klas Engwall

unread,
Oct 11, 2020, 6:33:32 AM10/11/20
to harbou...@googlegroups.com
Hi Simo / Francesco,

> There are some settings (sorry, I can't remember) to let harbour change
> filenames' case during such operations.

SET FILECASE LOWER
SET DIRCASE LOWER

will change the interpretation of all file and directory names to lower.
In addition to that, the -fn:l compiler switch converts any inconsistent
file names in the code to lower case.

Regards,
Klas

cod...@outlook.com

unread,
Oct 11, 2020, 6:36:49 AM10/11/20
to Harbour Users

Hi Francesco.

Lowercase file name did the job !

I changed TEST.DBF to test.dbf . All next commands worked:

USE ("test.dbf")

use ("test.dbf")

USE ("test")

use ("test")

Well, I must remember golden rule: In Linux keep all filenames in lowercase !! Did not expected that it is so important.

Thank you all.

Best Regards,

Simo.

Francesco Perillo

unread,
Oct 11, 2020, 6:52:10 AM10/11/20
to harbou...@googlegroups.com
Thanks Klas.

Can you please tell me what happens with use FILE and  there are the following files in the directory ?

file.dbf
File.dbf
FILE.DBF

--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.

cod...@outlook.com

unread,
Oct 11, 2020, 7:11:42 AM10/11/20
to Harbour Users

Hi Klas.

Thank you for your information.

In Windows I do not care about file names as all works same no matter how I name my files. It is good to now these settings and compiler switch when migrating to Linux.

I will try it also.

Best Regards,

Simo.


cod...@outlook.com

unread,
Oct 11, 2020, 10:31:01 AM10/11/20
to Harbour Users

Hi.

One last question, if you have any patience with me.

I can USE("test.dbf") when test.dbf is in same directory with executable file (I call it current directory).

But I can't open file that is not in current directory. For example this

USE("/data/sdata/test.dbf")  

do not work. It gives DBFNTX/1001 Open error TEST.dbf (DOS Error 2). I for sure have test.dbf in /data/sdata directory.

Also FILE("/data/sdata/test.dbf") return .F. This works in Windows without ant problems.

I tried with backslash  USE("\data\sdata\test.dbf") , again same error.

Is there some Linux rule for opening file that is not in current directory, using Harbour ? Linux do not have drive letter C: or D: as in Windows, so how can I type type paths (absolute or relative) in Linux?


Best Regards,

Simo.

cod...@outlook.com

unread,
Oct 11, 2020, 12:02:18 PM10/11/20
to Harbour Users

Hi.

Sorry to all. My mistake in  last question. I work all day, so I am tired.

USE("/data/sdata/test.dbf")  works good.

In beginning of my prg I forgot  that I tested

SET FILECASE LOWER 

SET DIRCASE LOWER

When I commented these SET commands, all works well. I did not use SET commands correctly.

Again thanks for all who gave me suggestions and guided me in Linux matters. No more questions.

 

Best Regards,

Simo.

Matthew Johnson

unread,
Oct 11, 2020, 12:13:19 PM10/11/20
to harbour-users
Try use // not /.  Or try use with ' not ". Single quote.  Or just use /directory/file no function.



--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.

Srđan

unread,
Jun 14, 2021, 2:44:50 AM6/14/21
to Harbour Users
In file included from ../../../png.c:14:
../../../pngpriv.h:44:12: fatal error: stdlib.h: No such file or directory
   44 | #  include <stdlib.h>
      |            ^~~~~~~~~~
compilation terminated.
Why get this error on Linux Mint 20?

Alain Aupeix

unread,
Jun 14, 2021, 3:35:11 AM6/14/21
to 'Srđan' via Harbour Users
Le 14/06/2021 à 08:44, 'Srđan' via Harbour Users a écrit :
> In file included from ../../../png.c:14:
> ../../../pngpriv.h:44:12: fatal error: stdlib.h: No such file or directory
>    44 | #  include <stdlib.h>
>       |            ^~~~~~~~~~
> compilation terminated.
> Why get this error on Linux Mint 20?


Here is what I have under Xubuntu 16.04

alain@Gramps-JujuLand2:/opt/TuxPrograms/trunks/harbour/src/3rd/png$ ls
LICENSE     png.diff    pnglconf.h  pngrio.c    pngtrans.c
Makefile    pngerror.c  pngmem.c    pngrtran.c  pngwio.c
png.c       pngget.c    pngpread.c  pngrutil.c  pngwrite.c
pngconf.h   png.h       pngpriv.h   pngset.c    pngwtran.c
pngdebug.h  pnginfo.h   pngread.c   pngstru.h   pngwutil.c

alain@Gramps-JujuLand2:/opt/TuxPrograms/trunks/harbour/src/3rd/png$ make
! Building Harbour 3.2.0dev from source - https://harbour.github.io
! MAKE: make 4.1 /bin/sh
! HB_HOST_PLAT: linux (x86_64)  HB_SHELL: sh
! LD_LIBRARY_PATH: /opt/TuxPrograms/trunks/harbour/lib/linux/gcc:
! HB_PLATFORM: linux (x86_64) (auto-detected)
! HB_COMPILER: gcc (auto-detected: /usr/bin/)
! HB_HOST_PKGM: deb
! Component: 'zlib' found in /usr/include
! Component: 'pcre' found in /usr/include
! Component: 'gpm' found in /usr/include
! Component: 'slang' found in /usr/include
! Component: 'curses' found in /usr/include
! Component: 'x11' found in /usr/include
! Component: 'wattcp/watt-32' not supported on linux platform
! HB_INSTALL_PREFIX automatically set to: /usr/local
! 'png' library skipped (unused)

It does nothing, probably I have this :

! 'png' library skipped (unused)

> On Sunday, October 11, 2020 at 6:13:19 PM UTC+2 mattfr...@yahoo.com wrote:
>
> On Oct 11, 2020 at 9:31 AM, cod...@outlook.com
> <cod...@outlook.com> wrote:
>>
>> Hi.
>>
>> One last question, if you have any patience with me.
>>
>> I can USE("test.dbf") when test.dbf is in same directory with
>> executable file (I call it current directory).
>>
>> But I can't open file that is not in current directory. For
>> example this
>>
>> USE("/data/sdata/test.dbf")
>>
>> do not work. It gives DBFNTX/1001 Open error TEST.dbf (DOS Error
>> 2). I for sure have test.dbf in /data/sdata directory.
>>
>> Also FILE("/data/sdata/test.dbf") return .F. This works in
>> Windows without ant problems.
>>
>> I tried with backslash  USE("\data\sdata\test.dbf") , again same
>> error.
>>
Normal you're not under windows
>
>> Is there some Linux rule for opening file that is not in current
>> directory, using Harbour ? Linux do not have drive letter C: or
>> D: as in Windows, so how can I type type paths (absolute or
>> relative) in Linux?
>>
If you're running the harbour program from a terminal and in the folder
where it is located (prog + dbf + ntx)

use "test" index "myindex"

ought to work ...

If you run from a link without specifying the folder where to run, you
must use the complete path, same if prog and data aren't in the same
folder (for harbour, obviously)

But as you write your line, it seems that data folder is located under
the root folder of the file system. If data is located just under the
prog folder, you ought to write : data/sdata/test.dbf

I don't know if  /data folder exists under Mint, it doesn't exist under
(X)ubuntu

A+
--
------------------------------------------------------------------------
*Alain Aupeix*
Sites web : JujuLand <http://jujuland.pagesperso-orange.fr/> |
Pissobi-Lacassagne <http://pissobi-lacassagne.pagesperso-orange.fr/> |
Gadel <https://www.gadel-environnement.org/>
------------------------------------------------------------------------
X.ubuntu 16.04 | H.arbour 3.2.0dev (r2021-03-31 18:37) | Hw.gui 2.22-4
(r2965) | G.ramps 5.1.2
------------------------------------------------------------------------

Reply all
Reply to author
Forward
0 new messages