Harbour, Linux and Debug

262 views
Skip to first unread message

Anderson Cardoso Silva

unread,
Jan 4, 2025, 8:37:59 PM1/4/25
to Harbour Users
How to compile Harbour program on Linux with debug?
It works fine on Windows but on Linux throw me errors.

Daniel L. Stuardo S.

unread,
Jan 4, 2025, 8:59:02 PM1/4/25
to harbou...@googlegroups.com

Amigo:

Uso Harbour 3.0 y 3.2 en Linux Debian desde hace años.
He notado algunos errores y muchos "warning" cuando lo construyo desde las fuentes, desde la versión 11 en adelante de Debian.
No sé qué distro usas, pero Harbour presenta estos problemas con las versiones aludidas. No son problemas fatales, puedo construir Harbour realizando pequeños cambios, pero siento que la versión para Linux está desactualizada y quizá dejada de lado.
Espero que puedas resolver tus problemas. Creo haber podido compilar con el debug activado, pero lo que uso normalmente para revisar mis programas es "valgrind".
En Dos/windows, uso "dr.memory", pero me arroja muchos falsos positivos.

Saludos!

Daniel Stuardo

Daniel L. Stuardo S.
   

El sáb, 4 de ene. de 2025 22:38, Anderson Cardoso Silva <acardo...@gmail.com> escribió:
How to compile Harbour program on Linux with debug?
It works fine on Windows but on Linux throw me errors.

--
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: https://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 visit https://groups.google.com/d/msgid/harbour-users/b51c6439-1c42-42c2-a14d-d95652036637n%40googlegroups.com.
Message has been deleted

Francesco Perillo

unread,
Jan 8, 2025, 10:00:47 AM1/8/25
to harbou...@googlegroups.com

I feel more than 50% of this answer is... well... of no value...


Il Mer 8 Gen 2025, 15:54 PSDurco <kimb...@gmail.com> ha scritto:
Hello friends, I also didn't know about this difficulty in debugging in Linux. In order to contribute to your question, and I already thank you for it because I learned one more point thanks to it, I ask permission to leave here the answer from HMG Assistant:

It's true that debugging Harbour applications can be more challenging on Linux compared to Windows. The reason lies in the way Harbour's debugging features and tools are implemented. Let's break this down:


Challenges with Debugging Harbour on Linux
  1. Harbour Debugger (hbdebugger):

    • Harbour has a built-in debugger (hbdebugger), but it was primarily designed for the Windows environment.
    • On Linux, hbdebugger may not always provide a smooth experience because:
      • The terminal-based debugging UI is less user-friendly.
      • Certain debugger features may not work as reliably as in Windows.
  2. Generated C Code:

    • Harbour generates C code as an intermediate step. Debugging on Linux often requires dealing directly with this C code using tools like gdb.
    • Debugging the C code isn't as intuitive as debugging Harbour's high-level xBase code.
  3. Integration with GDB:

    • While you can debug the generated C code using gdb, it doesn't provide the same insights into Harbour-specific constructs (e.g., Harbour functions, variables, etc.) as the Harbour debugger does on Windows.

Why Windows is Better for Debugging Harbour
  1. Better Debugger Support:

    • Windows has native tools that integrate seamlessly with Harbour's debugging framework.
    • GUI-based debuggers like Harbour MiniDebugger are available and user-friendly.
  2. Enhanced Compatibility:

    • Windows has historically been a more common environment for xBase programming, leading to more mature debugging tools and workflows.
  3. IDE Integration:

    • IDEs like Harbour MiniGUI IDE or xHarbour Builder offer better debugging features on Windows.

Workarounds for Linux
  1. Use GDB for Low-Level Debugging:

    • You can still debug your application using gdb, but you'll be working with C-level constructs.
    • Compile your application with debugging symbols (-g flag in GCC) to make this easier.
  2. Remote Debugging:

    • If you must debug at a Harbour level, consider setting up a remote debugging session with a Windows machine running Harbour tools.
  3. Enhanced Logging:

    • If full debugging isn't possible, use extensive logging to diagnose issues: ? "Debug: Variable X =", X
  4. Test Critical Parts on Windows:

    • Develop and debug your Harbour applications on Windows for critical portions, then test and finalize on Linux.
  5. Check Terminal Compatibility:

    • If you're using hbdebugger, ensure your terminal supports the required features. Some advanced Linux terminal emulators (e.g., tilix, konsole) might provide a better debugging experience.

Suggestions for Debian

If you're on Debian:

  • Ensure you have the latest version of Harbour compiled from source or installed via a compatible package.
  • Use a modern terminal emulator for better debugging output.
  • If the Harbour debugger proves inadequate, rely on hybrid debugging with GDB and Harbour runtime features.

While debugging on Linux may not be as seamless as on Windows, careful planning and the use of available tools can help bridge the gap. 

https://chatgpt.com/g/g-677a958937908191a7f31891201e6fb5-harbour-minigui-assistant

With my best regards, 

@PSDurco
Em sábado, 4 de janeiro de 2025 às 22:37:59 UTC-3, Anderson Cardoso Silva escreveu:
How to compile Harbour program on Linux with debug?
It works fine on Windows but on Linux throw me errors.

--
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: https://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.

PSDurco

unread,
Jan 8, 2025, 10:46:42 AM1/8/25
to Harbour Users
My friend, forgive me.

For me, it does have value, because I was out of the HMG "scene" for almost 15 years and could not follow all the developments and challenges over that time. And with this tool I am getting up to speed quickly and with great results, of course, I also already have some knowledge in HMG. But I am very rusty.

Forgive me once again, it was not my intention to cause anger or any bad feelings.

Alain Aupeix

unread,
Jan 8, 2025, 11:22:07 AM1/8/25
to harbou...@googlegroups.com, PSDurco

Another way is to build using hwgui debugger which is really nice.

A+

To view this discussion visit https://groups.google.com/d/msgid/harbour-users/37db2363-b231-4852-a132-01708c673d41n%40googlegroups.com.
--

Alain Aupeix
Sites web : JujuLand | Pissobi-Lacassagne | Gadel
X.ubuntu 16.04 | H.arbour 3.2.0-1 (r2024-09-14 21:26) | Hw.gui 2.23-8dev (r3481) | G.ramps 5.1.2


Itamar Lins

unread,
Jan 8, 2025, 12:00:56 PM1/8/25
to Harbour Users
Hi!
He uses putty/ssh to access, he doesn't have an X11 server installed, that's the reason for the error, he doesn't have ncurses, gpm...
The problem is trying to respond when all this information is missing.
He post same problem into brasilian forum pctoledo.

Best regards,
Itamar M. Lins Jr.

Francesco Perillo

unread,
Jan 8, 2025, 12:04:45 PM1/8/25
to harbou...@googlegroups.com

Yes the problem is that it tries to connect to  X server... that is the gui service in linux/Unix... the problem is way sooner than program start.

There are tons of missing informations.
Anyway I will try to create a simple Linux program and enable debugger.
I will also try to explain why I think the chatgpt answer adds very low information


Francesco Perillo

unread,
Jan 9, 2025, 2:50:25 AM1/9/25
to harbou...@googlegroups.com
Ok I just completed a really small test.

I created a test.prg file, on both windows and linux:

procedure main
altd(1)
? "First message"
inkey(0)
? "second message"

I compiled it on both windows and linux using this line:
hbmk2 -b test.prg

I run the program on both operating systems, then when "first message" appears I pressed Alt-D, nothing happens but as soon as I press another key to exit the inkey(0) the debugger kicks in on both windows and linux.

I attach a little screenshot

So debugging under linux is possible and it works in text mode.

We should have a look at how the linux executable is built that needs X server...
harbour-debug.png

Mario H. Sabado

unread,
Jan 9, 2025, 3:36:14 AM1/9/25
to 'elch' via Harbour Users
Hi Anderson,

If you're running on a terminal console, you may try to add //gtcrs parameter in your executable  (i.e., ./mydebugtest //gtcrs)

Regards,
Mario

On Sun, Jan 5, 2025, 9:38 AM Anderson Cardoso Silva <acardo...@gmail.com> wrote:
How to compile Harbour program on Linux with debug?
It works fine on Windows but on Linux throw me errors.

--
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: https://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.

wanst...@gmail.com

unread,
Feb 10, 2025, 12:36:00 PM2/10/25
to Harbour Users
Hi,

Alternative code:

procedure main
altd(1)
altd()
? "First message"
inkey(0)
? "second message"
return

My question is: Is it possible to open the DEBUG in a separate window?
I am running it on Windows 10 and using GTWVT.
Any information is welcome!
Thanks

-Mario

Alain Aupeix

unread,
Feb 10, 2025, 3:12:13 PM2/10/25
to harbou...@googlegroups.com, wanst...@gmail.com

An easy is to build it with hwgui and libhwgdebug.a

No obligation to use its gui.

Try HwMake for Linux : https://sourceforge.net/projects/hwmake/

A+

Reply all
Reply to author
Forward
0 new messages