Setting vscode for harbor debugging

364 views
Skip to first unread message

Joe Hicks

unread,
Oct 17, 2023, 8:45:36 PM10/17/23
to Harbour Users
I've spent almost a week so far trying to get this to work. 
When I run harbour debug helloharbour.exe I get an error compiling debug.prg
Error is f0029 Can't open #include file 'hbdebug.ch

That error was also showing when I loaded the file in vscode.
I switched the line for that include with the next one and the error in vscode editor went away but when I tried the command again I get the same thing.

debug.prg compiles with hbmk2 with no errors
I have set in the harbour extension, additional libraries = c:\harbour\include but that
doesn't help either.

manually running the statement:

harbour debug helloharbour -i"c:\harbour\include"  compiles with no errors but when I try to run it, it says could not find function main.
I added -n2 to the command and it compiles but when I run it it still says the same thing.
Very frustrated. I realize I could probably deal with harbour without debugging but it would really be helpful.  I'm about to try to do it all again in a different virtual machine from scratch and see if that helps. Would very much appreciate anyone's advice.

Eric Lendvai

unread,
Oct 18, 2023, 2:36:21 AM10/18/23
to Harbour Users
Are you trying https://github.com/EricLendvai/Harbour_Samples/tree/main/HelloHarbour  ?

with the debugger from the Harbour VS Code Extension

You may need to update it by using the instructions from the extension mentioned in the article.

Joe Hicks

unread,
Oct 18, 2023, 7:53:07 AM10/18/23
to harbou...@googlegroups.com
Thanks so much for answering. I was using the helloharbour in your reference. However, when I first set this up, I already had vscode on my 32-bit windows 8 virtual machine. I followed a youtube video to install ming32 to a c:\ming32 folder and harbour to c:\harbour where I ran the makefile to set it up (took almost an hour to run). I added the bin paths to the system path variable. hbmk2 works fine to compile and run anything I've tried.  I modified the debug.prg produced by harbour to match my folders. I was using the 32-bit operating system because I had an internal clipper database that I started in 1990 and updated it since.  (I program mostly in Delphi since it started but have used many other languages). The fact that harbour compiles to 32 (or I assume also 64 bit) exe's is great and would allow us to run the database on 64 bit windows. Will also allow me to extend the functions. Currently clipper says I can only add one more subroutine and re-indexing fails with an error. I already wrote a .prg to test the re-indexing and the reindexed cdx file indeed works with the dos clipper program -- amazing. Just the intellisense in vscode makes it so much better than my previous work in multi-edit. Unfortunately, database work is only maybe 1% of what I need to do but it still needs to be done.

I was planning on starting from scratch in a 64-bit vm and I'll try following your article referenced above (I don't think I had seen that one before). Hopefully that will get me going. Like I said, I could live with just vscode editing and compiling but it would be really nice to debug when needed.

I watched your 1 1/2 hour video on harbour yesterday -- was very impressed.
Thanks again for replying. 

--
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 a topic in the Google Groups "Harbour Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/harbour-users/h0m1Q2tWzgA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to harbour-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-users/6717f4f8-c6ed-4474-a3b2-cc7a0b9d6300n%40googlegroups.com.

Joe Hicks

unread,
Oct 18, 2023, 9:54:51 AM10/18/23
to harbou...@googlegroups.com
Apparently Mingw web installer is broken and has been for some time based on all the comments I've found. I did find a youtuber who suggested downloading the i686-8.1.0-release-win32-dwarf-rt_V6.rev0.7z which is the newest release but not an installer. The download definitely worked. They wanted it copied to c:\mingw32 -- very simple and way shorter for links. I'm sure it couldn't be copied to the program files(x86) folder as is. Apparently I did that download the first time as well. I can't see how that would matter but would have to change any references to the ProgFiles folder -- not a big deal.

Angel Pais

unread,
Oct 18, 2023, 10:13:57 AM10/18/23
to harbou...@googlegroups.com
If you are using windows only, in my experience, Visual Studio community edition is the best compiler for harbour.

HTH
Angel

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/CANuuy3EjX%2B9E90tugpKCYmmuPf4DvooRe9TuyWWPebOz85dfCg%40mail.gmail.com.

Joe Hicks

unread,
Oct 18, 2023, 11:20:36 AM10/18/23
to harbou...@googlegroups.com
Thanks but visual studio is such a huge footprint. I first tried to setup harbour in a 32-bit win8.1 vm because that's where my clipper code was. Had no trouble with mingw or harbour. Only problem was getting the debug to work. I started again today in a 64 bit win10 vm, trying to follow Eric Lendvai's article but have had nothing but problems. Web compiler is apparently broken. Had to download a snapshot version and just extract it into c:\mingw32. Harbour would not compile. This is on a win10 64 bit vm. It compiled with no problems on the 32-bit win 8.1 vm and what stupid default folder names for mingw -- what is it 70 characters wide especially when installed in Program Files (x86). Apparently Chrome has a new setting that blocks downloads that try to download multiple files. Was able to turn that off but that is only for souceforge. Have to keep an eye on that for other downloads.

I just checked and the buildinfo.txt for the win8.1 install and the win10 install are the same version.
Surely this should not be this difficult to set up.

Joe Hicks

unread,
Oct 18, 2023, 12:26:40 PM10/18/23
to harbou...@googlegroups.com
I was able to install the daily build of harbour so did not have to compile it. So this issue is off the table, though the daily build has all the executables directly in the bin folder instead of bin/win. Still it works so can't complain.

Eric Lendvai

unread,
Oct 18, 2023, 12:47:12 PM10/18/23
to Harbour Users
Thank Joe for the info. I had just tried to run the installer on a new machine and had the same problem. I was able to download the compressed file and simply decompress it to be able to use it. I will update the installation instructions in the article hopefully soon. I also started using the Microsoft C compiler instead on Windows since it works better when using the curl library. 
All the samples I provided in my repo are tested for 64-bit.
I stopped using 32-bit for a while now, especially since on Linux everything is 64 bit.
In my free time, I am now working in https://wharf.systems  which I will publish open source. It will be a great source of samples for creating mixed web and desktop apps. But its main goals is to assist Harbour and Python developers in creating web applications.
What time zone are you in Joe? I am near Seattle. Maybe we can connect via Skype and zoom.

Joe Hicks

unread,
Oct 19, 2023, 12:21:25 PM10/19/23
to Harbour Users
I've now spent all morning trying to figure out how to set up to use a lib version of debug -- NOTHING WORKED!
* I've successfully compiled debug as a  library with and without debug mode -- fails to go into debug mode
* tried to add the lib in the build.bat and compiles but won't debug.
* Changed the hbp file to accommodate and still no joy
* tried having hbmk2 make a ch file for the library and included that in the program -- Fails to find include and lib

I've looked at switching to use vscode (which I have in other virtual machines -- takes an hour to install and with only c++, still takes up 2 GIGS of space.
If there is a way to install just the compiler, I would like to know that. And I have to figure out how to change all the settings to make that work with harbour. 
Ok -- so that's possible.
I'm not even sure if harbour would have to be recompiled in visual studio.
Anyway unless someone can provide some instructions on how to proceed, I think I'm just going to continue using mingw and just skip the debugging
for now. I've spent more than a week on this and can't do more right now. I own Codegear Rad studio with Delphi and C++ so I guess if I really needed to debug, I 
could compile just to c code and debug it in delphi as just c-code--not the best solution to correct the harbour code but doable. Or like I used to have to 
do back then, add alert messages to the code and run it to find values.).

Alex Strickland

unread,
Oct 20, 2023, 10:28:08 AM10/20/23
to harbou...@googlegroups.com

Hi Joe

You are compiling with -b? And you are linking the debug source code that comes with Antonino Perricone's extension?

I don't specifically recall compiling any debug lib at all.

--

Regards

Alex

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/d08d3320-255a-4148-9c8d-f5195b4d11ffn%40googlegroups.com.

Joe Hicks

unread,
Oct 21, 2023, 12:45:09 PM10/21/23
to Harbour Users
Yes I've tried compiling using the Build script that eric lendvai had on his page. (I believe the actual statement executed was "harbour debug.prg myprog.prg -b").  It gave an error, could not find whatever first ch file that was listed. I switched the first ch with the second and again the error named the first ch as couldn't be found. I added an include lib statement and the error was "could not find entrypoint Main".  I saw in one of the articles that it would be better to make the debug.prg into a lib file and then include it in the build. I could not find any other instructions for doing that, i.e. does it have to be build with -b, where to put it, how to link in into the build, etc. I tried a number of ways and got no error but also the debug screen would only flash for a second then go away. 
So as it sits, I can use vscode to write code and at least it catches most syntax errors and that's way better than the old multi-edit or notepad. Then have to open a console to compile using hbmk2. To debug and  find specific variable values, I have to insert alert statements, the same as I always used to do when writing clipper code. I'm sure I can eventually set up tasks to compile and run a program using batch script files. Not even sure I can't just use hbmk2 commands in the batch. Will have to look more. Need to learn much more about vscode. Have only been using it for a couple of months, mainly for html coding, and only the past 10 days or so for harbour. Possibly learning more about vscode debugging in general will be helpful. Thanks for responding.

Alex Strickland

unread,
Oct 22, 2023, 1:19:09 PM10/22/23
to harbou...@googlegroups.com

Hi Joe

Where does debug.prg come from? There is one in the source tree of Harbour 3.2 but it doesn't really have anything to do with debugging.

I looked at https://github.com/EricLendvai/Harbour_Samples/tree/main/HelloHarbour but I don't see any debug.prg there.

There is a source file that you download from Antonino Perricone's repository via the VSCode command "Harbour: Get debugger code". Are you naming that file debug.prg? The file that you download can be called anything and you should include it in your hbp file (or otherwise make sure it is compiled and the object file linked). I call it hbvscdebug.prg. That is all I do to enable the VS Code debugging (and compile with -b).

I hope you win, it's fantastic although it does occasionally have its own oddities.

--

Regards

Alex

Eric Lendvai

unread,
Oct 22, 2023, 4:29:47 PM10/22/23
to Harbour Users
Thanks Alex, 

But you should always update it with the version from your Harbour extension installed in your VSCode.

In the https://github.com/EricLendvai/Harbour_Samples/blob/main/BuildTools/BuildEXE.bat I actually add the vscode_debugger.prg to the hbmk2 call only when compiling for debugging.

Extract from the BuildEXE.bat
========================
if %BuildMode% == debug (
    hbmk2 "%EXEName%_windows.hbp" ..\BuildTools\vscode_debugger.prg -b -p -dDEBUGVIEW -dDONOTINCLUDE -workdir="%ROOT_PATH%\build\win64\%HB_COMPILER%\%BuildMode%\hbmk2\"
) else (
    hbmk2 "%EXEName%_windows.hbp" -dDONOTINCLUDE -workdir="%ROOT_PATH%\build\win64\%HB_COMPILER%\%BuildMode%\hbmk2\" -static
)

Could anyone in this forum test out my samples, or at least the HelloHarbour one?
I just would like to be certain what I pushed to the repo is working fine.
Thanks.
Reply all
Reply to author
Forward
0 new messages