Search code examples
zig

what are the rules zig build-lib uses for shared objects filenames?


I have a sqlite extension file. The source is sqliteext/csv.c. When I build the lib with clang the output file is created at lib/csv.so.

cc -g -fPIC -I /usr/local/include -shared sqliteext/csv.c -o lib/csv.so

When I compile the lib using zig...

zig build-lib -I /usr/local/include -I /usr/include -I /usr/include/x86_64-linux-gnu --c-source sqliteext/csv.c -dynamic --output-dir lib

There are two problems.

  • zig prefixes the filename with a lib
  • zig add a version number thing in the suffix

so the output file is lib/libcsv.so.0.0.0

And what's interesting about this is that I need to change the filename in my extension loader (that's ok) but that I also need a symlink to handle the 0.0.0.

I'm still looking at the CLI help but I'm still not seeing the thing I need.


Solution

  • See https://github.com/ziglang/zig/issues/2230 and https://github.com/ziglang/zig/issues/2231

    The former was fixed the same day as your post via https://github.com/ziglang/zig/pull/6315