script for make harbour(source) using zig with msys2

157 views
Skip to first unread message

Itamar Lins

unread,
Nov 3, 2025, 2:22:35 PMNov 3
to Harbour Developers
Hi!
There's no error when compiling the source code; it only says it can't find the file after copying it. Isn't this the line that's deleting the file after it's created?

( del /q /f ..\..\..\..\..\..\lib\win\zig\libpng.a && mkdir . 2> nul ) 

( zig ar    rcs ../../../../../../lib/win/zig/libpng.a png.o pngerror.o pngget.o pngmem.o pngpread.o pngread.o pngrio.o pngrtran.o pngrutil.o pngset.o pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o  ) || ( del /q /f ..\..\..\..\..\..\lib\win\zig\libpng.a && mkdir . 2> nul )
ar: error: unable to open '../../../../../../lib/win/zig/libpng.a': No such file or directory

Best regards,
Itamar M. Lins Jr.

Aleksander Czajczynski

unread,
Nov 3, 2025, 2:41:12 PMNov 3
to harbou...@googlegroups.com
Hello!

Don't use zig from MSYS2 packages - "zig ar" command is broken there somehow, also being older version last time I've checked. You can download standalone from zig-lang.org and call it from this shell too.

Best regards, Aleksander

Itamar Lins wrote:
Itamar M. Lins Jr. --
You received this message because you are subscribed to the Google Groups "Harbour Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-deve...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/harbour-devel/22db5882-717f-43de-b63f-8d5bf5f5f0bcn%40googlegroups.com.

Itamar Lins

unread,
Nov 4, 2025, 2:58:43 PMNov 4
to Harbour Developers
Hi!
Thank you for responding. I've been looking and this way below works. Without the word zig, just ar. 

ar rcs libpng.a png.o pngerror.o pngget.o pngmem.o pngpread.o pngread.o pngrio.o pngrtran.o pngrutil.o pngset.o pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o

04/11/2025  16:53         1.053.666 libpng.a
04/11/2025  16:31           115.837 png.o
04/11/2025  16:31            48.448 pngerror.o
04/11/2025  16:31            72.793 pngget.o
04/11/2025  16:31            31.323 pngmem.o
04/11/2025  16:31            50.024 pngpread.o
04/11/2025  16:31            99.803 pngread.o
04/11/2025  16:31            21.914 pngrio.o
04/11/2025  16:31           108.214 pngrtran.o
04/11/2025  16:31           129.620 pngrutil.o
04/11/2025  16:31            80.145 pngset.o
04/11/2025  16:31            40.461 pngtrans.o
04/11/2025  16:31            22.375 pngwio.o
04/11/2025  16:31            73.214 pngwrite.o
04/11/2025  16:31            28.922 pngwtran.o
04/11/2025  16:31           112.724 pngwutil.o
Tested with zig 0.15.2


Best regards,
Itamar M. Lins Jr.

Itamar Lins

unread,
Nov 4, 2025, 5:31:40 PMNov 4
to Harbour Developers
Hi!
After reading a bit more, I found what you already explained; it's a known bug, and it asks to use llvm-ar as the official solution while they haven't finished it yet, maybe in version 0.16...
llvm-ar rcs ...


Best regards,
Itamar M. Lins Jr.

Itamar Lins

unread,
Nov 4, 2025, 6:54:26 PMNov 4
to Harbour Developers
Hi!
Just to let you know.
I modified the files common\zig.mk and \utils\hbmk2\hbmk2.prg
Of course, many errors and warnings appeared.

Line change config\zig.mk
AR := llvm-ar #zig ar

set hb
HB_COMPILER=zig
HB_INSTALL_PREFIX=c:\hbzig
HB_STATIC_CURL=yes
HB_STATIC_OPENSSL=yes
HB_WITH_CURL=C:\msys64\clang64\include
HB_WITH_MYSQL=C:\msys64\clang64
HB_WITH_ODBC=C:\msys64\clang64
HB_WITH_OPENSSL=C:\msys64\clang64\include
HB_WITH_PGSQL=C:\msys64\clang64\bin
...
! Finished package build and install...
./bin/win/zig/hbmk2.exe ./config/postinst.hb install
! Copying root documents...
! Copying Harbour script files...
! Making core translation (.hbl) files...
! Created c:\hbzig\bin\hbmk2.el.hbl <= utils\hbmk2\po\hbmk2.el.po
! Created c:\hbzig\bin\hbmk2.en.hbl <= utils\hbmk2\po\hbmk2.en.po
! Created c:\hbzig\bin\hbmk2.es.hbl <= utils\hbmk2\po\hbmk2.es.po
! Created c:\hbzig\bin\hbmk2.es_419.hbl <= utils\hbmk2\po\hbmk2.es_419.po
! Created c:\hbzig\bin\hbmk2.fr.hbl <= utils\hbmk2\po\hbmk2.fr.po
! Created c:\hbzig\bin\hbmk2.gl.hbl <= utils\hbmk2\po\hbmk2.gl.po
! Created c:\hbzig\bin\hbmk2.hu.hbl <= utils\hbmk2\po\hbmk2.hu.po
! Created c:\hbzig\bin\hbmk2.it.hbl <= utils\hbmk2\po\hbmk2.it.po
! Created c:\hbzig\bin\hbmk2.pt_BR.hbl <= utils\hbmk2\po\hbmk2.pt_BR.po
! Compiling core documentation (.hbd)...
! Created c:\hbzig\doc\harbour.hbd <= .\
! Compiling list of contrib functions (.hbr)...
! postinst script finished

Line change hbmk2.prg
ELSEIF hbmk[ _HBMK_cCOMP ] == "zig"
            cBin_Lib := "llvm-ar" //"zig" + hbmk[ _HBMK_cCCEXT ] + " ar"


Best regards,
Itamar M. Lins Jr.

Mario H. Sabado

unread,
Nov 4, 2025, 7:36:06 PMNov 4
to harbou...@googlegroups.com
Hi Itamar,

I have tested to build the latest Harbour with Zig using version 0.15.x and 0.16.x dev and were built successfully.  I have the zig location in my PATH and ensure that I have no direct call to other executables (i.e. \mingw64\bin, \msys64\clang64\bin, \msys64\usr\bin).

Best regards,
Mario

Mario H. Sabado

unread,
Nov 4, 2025, 8:59:53 PMNov 4
to harbou...@googlegroups.com
Here's my Harbour environment for further info.

C:\harbour64>set hb
HBRUN_WITH_HEADERS=yes
HB_BUILD_CONTRIB_DYN=no
HB_BUILD_DYN=no
HB_BUILD_VERBOSE=yes
HB_COMPILER=zig
HB_CPU=x86_64
HB_INSTALL_PREFIX=\harbour64
HB_MT=yes
HB_PLATFORM=win
HB_QTPATH =c:\qt\qt5.12.12\5.12.12\mingw73_64\bin
HB_QT_SOUND=yes
HB_REBUILD_EXTERN=yes
HB_ROOT_=\harbour64
HB_STATIC_OPENSSL=yes
HB_USER_CFLAGS=-DHB_OPENSSL_MSYS
HB_USER_LIBPATHS=\msys64\clang64\lib
HB_WITH_CAIRO=\msys64\clang64\include\cairo
HB_WITH_FIREBIRD=C:\firebird\firebird_5_0\include
HB_WITH_MYSQL=\msys64\clang64\include\mariadb
HB_WITH_OPENSSL=\msys64\clang64\include
HB_WITH_QT=c:\qt\qt5.12.12\5.12.12\mingw73_64\include
HB_WITH_SQLITE3=yes
HB_ZIG_TARGET=x86_64-windows
Reply all
Reply to author
Forward
0 new messages