Closed mizlan closed 1 year ago
I've successfully compiled! One question though: how may I get the .a
and .so
files for the C library? I will need both of them.
@mizlan Looks like I should add some better instructions for how to set up zf for those unfamiliar with Zig :)
To compile the library, I would do the following
$ zig build-lib -OReleaseSafe -static src/clib.zig
$ zig build-lib -OReleaseSafe -dynamic src/clib.zig
And in this case, you don't even need to clone the submodule because the fuzzy finding interface doesn't (currently) require ziglyph.
You can also specify the exact output filename with the -femit-bin=<path>
option. And you can look at the justfile
in my telescope-zf-native.nvim project for an example of cross-compiling.
There currently isn't a header file so you will have to make your own. I'm happy to help with that too if you need it.
Got it! Now I ran objdump -t libzf.a
but it doesnt seem like there are exported symbols that are function names?
I just wrote this simple C program to test
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
// declare the external function
double rank(
const char *str,
const char **tokens,
uint64_t num_tokens,
bool case_sensitive,
bool plain
);
int main() {
const char *tokens[1] = { "t" };
double r = rank("test", tokens, 1, true, false);
printf("the rank: %f\n", r);
return 0;
}
And compiled with zig cc main.c libzf.a
. I executed the output a.out
file and everything works for me.
And I'm not an expert on the output of objdump, so I'm not sure why the symbols don't show the functions. But things do work... :)
There currently isn't a header file so you will have to make your own. I'm happy to help with that too if you need it.
Hmm. I think I will need one. I think the build system I'm using right now uses -c
to skip linking.
Edit: going to try -femit-h
Seems like it is a bit sketchy getting zig.h
which is included when using -femit-h
. There are a number of open github issues e.g., https://github.com/ziglang/zig/pull/14576
Okay, let me take some time to write some better docs and an .h file and I'll let you know when that's ready.
I think the build system I'm using right now uses -c to skip linking.
If you don't mind sharing, it would be helpful to know more about what you are doing. It might give more context into how I can assist
I think I've resolved everything to do with the Zig side, but unfortunately the API I'm using on the other end (ocaml-ctypes, with dune) is still experimental, so I think I will port the zf algorithm to OCaml actually. I will take a read through the (very tidy!) codebase.
I think I've resolved everything to do with the Zig side, but unfortunately the API I'm using on the other end (ocaml-ctypes, with dune) is still experimental
Unfortunate :( I hope your OCaml version works well!
Attempting to build tag 0.8.0 from source with Zig 0.10.1, which is the "latest stable Zig" as specified in the readme, fails with this error:
Edit: the above is my bad, the option is not present in the readme in 0.8.0, however I'm still running into problems.
If I omit that flag I run into dependency errors, which is reasonable since I don't have
ziglyph
package on my system, but I don't know how 0.8.0 brought that dependency in. There is no .zon file in that tree.I would overall like clearer instructions for how to build
zf
for someone with minimal Zig knowledge.edit: nevermind, i figured it all out (git submodules) i'm a bit dumb, i'm getting there hehe