MyZql unable to build

Hi I’m noob, spent some hours today with Zig, doing some micro-benchmarks and comparisons
(very promising)

I wanted to stress test the Mysql connection,
I’ve found this package: GitHub - speed2exe/myzql-example: example of usage for mysql

and used the files here: GitHub - speed2exe/myzql-example: example of usage for mysql
with this path tree:

./src/main.zig
./build.zig.zon
./build.zig

on a clean folder, when using “zig build”
(zig version 0.12)
I get this error:

/root/.cache/zig/p/1220582ea45580eec6b16aa93d2a9404467db8bc1d911806d367513aa40f3817f84c/build.zig:14:16: error: no field named 'filter' in struct 'Build.Step.Compile'
    unit_tests.filter = test_filter;
               ^~~~~~
/usr/local/bin/zig/lib/std/Build/Step/Compile.zig:1:1: note: struct declared here
const builtin = @import("builtin");
^~~~~
referenced by:
    runBuild__anon_15309: /usr/local/bin/zig/lib/std/Build.zig:2079:27
    dependencyInner__anon_14169: /usr/local/bin/zig/lib/std/Build.zig:2060:29
    remaining reference traces hidden; use '-freference-trace' to see all reference traces

I have no idea if this is user error
or if the package is perpahs broken with zig 0.12

It would be great if you can check this package with me, if you can replicate the issue.

Thank you,
Vidal

Welcome to the forum, @MVidal

The error is saying that there is not member of the Compile struct called filter. There is a filters and it takes a slice of slices, but no filter member.

In fact, filter was deprecated at some point in the past:

/// deprecated: use `.filters = &.{filter}` instead of `.filter = filter`.

That line of code in your source can be corrected via:

unit_tests.filters = &.{ test_filter };

However, running through both the source at the repo (from both links), I’m not seeing anything of the sort there. I tried building on 13.0 which is what my local machine is on and it failed for a different reason, so I can’t help much here on the 12.0 hunt, but hopefully that gives someone something to start from.

I think @squeek502 or @castholm would be the best people to answer this given the git history.

2 Likes

The example code is using the version 0.0.8 of the library.
Library README says that version 0.0.9 corresponds to zig 0.12.0.

From the example directory, run: zig fetch --save https://github.com/speed2exe/myzql/archive/refs/tags/0.0.9.tar.gz this shall update build.zig.zon to use version 0.0.9

2 Likes

Thank you @dimdin you are correct.

It now progresses further.

I’m now getting this:

install
└─ install myzql-example
   └─ zig build-exe myzql-example Debug native 1 errors
src/main.zig:7:9: error: use of undeclared identifier 'allocator'
        allocator,
        ^~~~~~~~~
error: the following command failed with 1 compilation errors:
/usr/local/bin/zig/zig build-exe -ODebug --dep myzql -Mroot=/root/zigStuff/09_mysqlConnForBench/src/main.zig -Mmyzql=/root/.cache/zig/p/12203840d31971a3737e19b377e1f0f14dbacfeedb12cb433271f7e627098cef5668/src/myzql.zig --cache-dir /root/zigStuff/09_mysqlConnForBench/zig-cache --global-cache-dir /root/.cache/zig --name myzql-example --listen=- 
Build Summary: 0/3 steps succeeded; 1 failed (disable with --summary none)
install transitive failure
└─ install myzql-example transitive failure
   └─ zig build-exe myzql-example Debug native 1 errors
error: the following build command failed with exit code 1:
/root/zigStuff/09_mysqlConnForBench/zig-cache/o/f46e2bda374be2cb6990dbb35f9b6d5b/build /usr/local/bin/zig/zig /root/zigStuff/09_mysqlConnForBench /root/zigStuff/09_mysqlConnForBench/zig-cache /root/.cache/zig --seed 0x1e0b42b8 -Z7370bdf5b04a2346

… I’ll bother the package maintainer :slight_smile:

user error, sorry everyone and thank you :slight_smile: