Compiling Harbor using Clang or Zig

147 views
Skip to first unread message

Itamar Lins

unread,
Oct 20, 2025, 7:59:20 PM (10 days ago) Oct 20
to Harbour Users
Hi!
I'm having trouble compiling Harbor using Clang or Zig. Using mingw64 works.
Using Msys2. I get this error.

zig cc -I. -I../../../../../include -Wno-error=date-time -W -Wall -O3 -DUNICODE -onortl.o -c ../../../nortl.c
( zig ar rcs ../../../../../lib/win/zig/libhbnortl.a nortl.o ) || ( del /q /f ..\..\..\..\..\lib\win\zig\libhbnortl.a && mkdir . 2> nul )
copy ..\..\..\macro.yyc macroy.c
zig cc -I. -I../../../../../include -Wno-error=date-time -W -Wall -O3 -DUNICODE -ol_be.o -c ../../../l_be.c
1 arquivo(s) copiado(s).
ar: copy ..\..\..\macro.yyh macroy.h
zig cc -I. -I../../../../../include -Wno-error=date-time -W -Wall -O3 -DUNICODE -ocp_950.o -c ../../../cp_950.c
error: zig cc -I. -I../../../../../include -Wno-error=date-time -W -Wall -O3 -DUNICODE -ol_be_dyn.o -DHB_DYNLIB -c ../../../l_be.c
zig cc -I. -I../../../../../include -Wno-error=date-time -W -Wall -O3 -DUNICODE -oexpropt1.o -c ../../../expropt1.c
unable to open '../../../../../lib/win/zig/libhbnortl.a': No such file or directory
copy ..\..\..\harbour.yyc harboury.c
zig cc -I. -I../../../../../include -Wno-error=date-time -W -Wall -O3 -DUNICODE -ocp_950_dyn.o -DHB_DYNLIB -c ../../../cp_950.c
Não foi possível encontrar C:\dev\hb32\lib\win\zig\libhbnortl.a

Best regards,
Itamar M. Lins Jr.

Itamar Lins

unread,
Oct 20, 2025, 8:06:00 PM (10 days ago) Oct 20
to Harbour Users
Hi!
With clang, i get this error.
...
clang -I. -I../../../../../../include -Wmissing-braces -Wreturn-type -Wformat -Wimplicit-int -Wimplicit-function-declaration -O3 -DUNICODE -IC:/dev/hb32/src/3rd/zlib -DPNG_NO_STDIO -DPNG_ARM_NEON_OPT=0 -opng.o -c ../../../png.c
process_begin: CreateProcess(NULL, clang -I. -I../../../../../../include -Wmissing-braces -Wreturn-type -Wformat -Wimplicit-int -Wimplicit-function-declaration -O3 -DUNICODE -IC:/dev/hb32/src/3rd/zlib -DPNG_NO_STDIO -DPNG_ARM_NEON_OPT=0 -opng.o -c ../../../png.c, ...) failed.
make (e=2): O sistema nÒo pode encontrar o arquivo especificado.
../../../../../../config/rules.mk:88: recipe for target 'png.o' failed
win-make.exe[4]: *** [png.o] Error 2
../../../config/lib.mk:68: recipe for target 'descend' failed
win-make.exe[3]: *** [descend] Error 2
../../config/dir.mk:68: recipe for target 'png.inst' failed
win-make.exe[2]: *** [png.inst] Error 2
../config/dir.mk:68: recipe for target '3rd.inst' failed
win-make.exe[1]: *** [3rd.inst] Error 2
config/dir.mk:68: recipe for target 'src.inst' failed
win-make.exe: *** [src.inst] Error 2


Best regards,
Itamar M. Lins Jr.

Message has been deleted

Itamar Lins

unread,
Oct 20, 2025, 9:49:46 PM (10 days ago) Oct 20
to Harbour Users
Hi!
CLANG resolved.
Fix, incomplet install of clang using msys2 command pacman


Best regards,
Itamar M. Lins Jr.



Aleksander Czajczyński

unread,
Oct 21, 2025, 3:45:53 AM (10 days ago) Oct 21
to Harbour Users
If you've been installing Zig using  pacman, then this one doesn't work for me. Either it's not the latest or it has something altered - "zig ar" command didn't work more precisely. Zig in MSYS here was 15.1, Zig from the official website is newer.

The option may be to call standalone Zig from MSYS shell - it seems to work.

Best regards, Aleksander

gfil...@gmail.com

unread,
Oct 21, 2025, 5:57:05 AM (10 days ago) Oct 21
to Harbour Users
Hi Aleksander,

I have a small question.
When I compile in GUI mode (using gt=gtgui in .hbc config) with zig compiler, I get two window: gui and console.
How to disable the console window for that case?
BTW there is NO that problem in MinGW build.

My compile log is below:
hbmk2: Processing environment options: -plat=win -comp=zig
hbmk2: Using Harbour: c:\project\harbour\bin c:\project\harbour\include
       c:\project\harbour\lib\win\zig c:\project\harbour\bin
       c:\project\harbour\contrib c:\project\harbour\addons
hbmk2: Processing: zig64.hbc
hbmk2: Compiling Harbour sources...
hbmk2: Harbour compiler command (built-in):
(c:\project\harbour\bin\harbour.exe) -n2 myapp.prg -q0 -DHBMK_HAS_ZIG64=1 -o..\bin\build\zig\ -ic:\project\harbour\include -i..\minigui\include -i..\harbour\include
hbmk2: Compiling resources...
hbmk2: Resource compiler command:
zig.exe rc /C 1252  -Ic:/project/harbour/include -I../minigui/include -I../harbour/include /FO ../bin/build/zig/myapp.res myapp.rc
hbmk2: Compiling...
hbmk2: C/C++ compiler command job #1:
zig.exe cc -c -O3 -fomit-frame-pointer  -target x86_64-windows-gnu -W -Wall -pipe -Ic:/project/harbour/include -I../minigui/include -I../harbour/include ../bin/build/zig/myapp.c -o ../bin/build/zig/myapp.o
hbmk2: C/C++ compiler command job #2:
zig.exe cc -c -O3 -fomit-frame-pointer  -target x86_64-windows-gnu -W -Wall -pipe -Ic:/project/harbour/include -I../minigui/include -I../harbour/include ../bin/build/zig/_hbmkaut_myapp.c -o ../bin/build/zig/_hbmkaut_myapp.o
hbmk2: Linking... ..\bin\myapp.exe
hbmk2: Linker command:
zig.exe cc ../bin/build/zig/myapp.o ../bin/build/zig/_hbmkaut_myapp.o  ../bin/build/zig/myapp.res  -mwindows -lminigui -lhbprinter -lminiprint2 -lbostaurus -lhbct -lhbhpdf -llibhpdf -lhbvpdf -lhbtip -lhbwin -lxhb -lpng -lhbmisc -lhbmzip -lminizip -luser32 -lgdi32 -lcomctl32 -lcomdlg32 -lshell32 -ladvapi32 -lole32 -lhbextern -lhbdebug -lhbvm -lhbrtl -lhblang -lhbcpage -lgtcgi -lgtpca -lgtstd -lgtwin -lgtwvt -lgtgui -lhbrdd -lhbuddall -lhbusrrdd -lrddntx -lrddcdx -lrddnsx -lrddfpt -lhbrdd -lhbhsx -lhbsix -lhbrtl -lhbvm -lhbmacro -lhbcplr -lhbpp -lhbcommon -lhbmainwin -lwinmm -lkernel32 -luser32 -lgdi32 -ladvapi32 -lws2_32 -liphlpapi -lwinspool -lcomctl32 -lcomdlg32 -lshell32 -luuid -lole32 -loleaut32 -lmpr -lmapi32 -limm32 -lmsimg32 -lwininet -lhbpcre -lhbzlib   -s -o../bin/myapp.exe  -Lc:/project/harbour/lib/win/zig -L../minigui/lib -L../harbour/lib/win/zig

Thanks in advance,
Grigory Filatov

вторник, 21 октября 2025 г. в 09:45:53 UTC+2, Aleksander Czajczyński:

Aleksander Czajczyński

unread,
Oct 21, 2025, 6:46:23 AM (10 days ago) Oct 21
to Harbour Users
I haven't looked into equivalent of /SUBSYSTEM parameter yet. Thanks for the report. In the meantime you can experiment with HB_USER_LDFLAGS=-Wl,-subsystem:windows
I'll review it later.

Best regards, Aleksander

Aleksander Czajczyński

unread,
Oct 21, 2025, 7:10:01 AM (10 days ago) Oct 21
to Harbour Users
Seems like it expected a mix of gcc and msvc syntax...

            IF hbmk[ _HBMK_lGUI ]
               AAdd( hbmk[ _HBMK_aOPTL ], "-Wl,/subsystem:windows" )
            ENDIF

I'll commit that in a sec.

Best regards, Aleksander

wtorek, 21 października 2025 o 11:57:05 UTC+2 gfil...@gmail.com napisał(a):

gfil...@gmail.com

unread,
Oct 21, 2025, 7:24:47 AM (10 days ago) Oct 21
to Harbour Users
Thanks a lot!

This issue was solved with
ldflags=-Wl,/subsystem:windows
in the local .hbc file.

Regards,
Grigory
вторник, 21 октября 2025 г. в 13:10:01 UTC+2, Aleksander Czajczyński:
Reply all
Reply to author
Forward
0 new messages