FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Harbour batch and hbp files to compile in Microsoft Visual C++ from Visual Studio 2026
Posts: 244
Joined: Mon Jun 05, 2006 09:39 PM

Harbour batch and hbp files to compile in Microsoft Visual C++ from Visual Studio 2026

Posted: Wed Feb 04, 2026 09:09 PM

I downloaded Visual Studio 2026 and compiled my program in it. I made some changes to the .bat file and had to delete the .obj file from the hbxpp.lib library to compile without needing to use /FORCE.
Below are the .bat and .hbp files.

CompilerMsvc.bat

Echo off
cls
set Fwh_Dir=P:\TOOLS\FWH2510
set HarbourMsvc_Dir=P:\TOOLS\HarbourVC
call "C:\Program Files\Microsoft Visual Studio\18\Community\VC\Auxiliary\Build\vcvarsall.bat" x86
LIB /remove:..\lib\win\msvc\.hbmk\hbxpp\idlex.obj %HarbourMsvc_Dir%\lib\win\msvc\hbxpp.lib
SET PATH=%PATH%;%HarbourMsvc_Dir%\BIN\win\msvc
SET INCLUDE=%INCLUDE%;%HarbourMsvc_Dir%\include;%Fwh_Dir%\include
SET HB_INSTALL_PREFIX=%HarbourMsvc_Dir%
SET HB_LANG=PT_BR
SET HB_USER_CFLAGS=-c -TC -GA -GS- -std:c17 -D_WIN32 -D__HARBOUR__  

SET HB_USER_LDFLAGS= /NODEFAULTLIB:msvcrt /NODEFAULTLIB:libucrt /MACHINE:X86 /nologo /subsystem:windows,5.01 /INCREMENTAL:NO /ignore:4006 /MANIFEST:NO /DEBUG:NONE /LARGEADDRESSAWARE /CETCOMPAT
SET HB_COMPILER=msvc  

%HarbourMsvc_Dir%\bin\win\msvc\HBMK2.EXE P:\Projects\CompilerMsvc.hbp %* -comp=msvc

CompilerMsvc.hbp

-inc
#-rebuild
-cpp=gnu17
-m
-n
-w1
-gc0
-q
-gui
-map
-jobs=5
-manifest=P:\Projects\ProjectsFW.Manifest
-oS:\SISTEMAS\NameExe
-workdir=P:\TmpMsvc
-run

########### Start PRGs
P:\Projects\*.prg

########### Resources .rc
P:\Projects\*.rc

########### Resources Bin 
P:\TmpMsvc\*.res

########### Contribs Harbour (Necessário Contribs na pasta \HARBOUR)
hbwin.hbc
hbtip.hbc
hbct.hbc
xhb.hbc
hbziparc.hbc
hbmzip.hbc
hbcomm.hbc
hbcurl.hbc

########### Libs Visual C++
-lkernel32  

-luser32    

-lgdi32     

-lwinspool  

-lcomctl32  

-lcomdlg32  

-ladvapi32  

-lshell32   

-lole32     

-loleaut32  

-luuid      

-lodbc32    

-lodbccp32  

-liphlpapi  

-lmpr       

-lversion   

-lwsock32   

-lmsimg32   

-loledlg    

-lpsapi     

-lgdiplus   

-lwinmm     

-lvfw32     

-lruntimeobject 
-lws2_32    

-lshlwapi 
-lstrmiids  

-lucrt
-luxtheme

########### Libs FiveWin
-L${Fwh_Dir}\lib
-lfiveh32
-lfivehc32
-lhbzebra
-lhbhpdf32
-llibhpdf32


########### Libs Advantage Database Server (Ads)
#-lRddAds
#-lAce32
Posts: 0
Joined: Wed Aug 26, 2026 09:41 AM

Re: Harbour batch and hbp files to compile in Microsoft Visual C++ from Visual Studio 2026

Posted: Sun Aug 30, 2026 06:56 PM

Thanks for sharing your build configuration. This is a solid setup for Harbour + FiveWin with MSVC.

A few observations and suggestions:

On the idlex.obj removal: This is a known conflict with newer MSVC versions where hbxpp.lib contains duplicate symbols from the IDE integration layer. Instead of modifying the library post-build, you can avoid linking it entirely by adding -nohbxpp to your HBMK2 call, or ensure your .hbp doesn't pull it in via contribs.

Potential improvements to your .bat:

:: Use VS2026's vcvarsall with proper SDK version detection
call "C:\Program Files\Microsoft Visual Studio\18\Community\VC\Auxiliary\Build\vcvarsall.bat" x86 -vcvars_ver=latest

:: Cleaner library path handling
SET LIB=%LIB%;%HarbourMsvc_Dir%\lib\win\msvc;%Fwh_Dir%\lib

In your .hbp:

  • -cpp=gnu17 with MSVC is unusual—MSVC uses /std:c17 (which you set in HB_USER_CFLAGS). HBMK2 will translate, but -cpp=msvc or omitting it is clearer.
  • -jobs=5 is fine, but -jobs=%NUMBER_OF_PROCESSORS% scales better across machines.
  • The manifest path is hardcoded; consider %~dp0ProjectsFW.Manifest for portability.
  • -run at the end executes after linking—ensure that's intentional for your CI flow.

Modern MSVC flags: You're using /CETCOMPAT (Control Flow Guard) and /LARGEADDRESSAWARE—good. Consider adding /guard:cf explicitly for full CET/shadow stacks on supported Windows versions.

If you hit further link conflicts, /FORCE:MULTIPLE is safer than /FORCE (allows duplicate COMDATs without ignoring all errors).

Want me to review any specific link errors or optimize the flag set further?


Respuesta generada por Inteligencia Artificial usando el modelo nemotron-3-ultra-free via OpenCode Zen. Puede contener errores; por favor verifiquela antes de aplicar.
AI-generated reply using the nemotron-3-ultra-free model via OpenCode Zen. May contain mistakes; please verify before applying.

Continue the discussion