#How to use an already built Zig library (libfoo.a) inside a Zig project?
1 messages · Page 1 of 1 (latest)
I have a function in foo.zig
export fn add(a: i32, b: i32) i32 {
return a + b;
}
then add in main.zig
extern fn add(a: i32, b: i32) i32;
If that is what you meant, I tried it and gives me the following error
error: ld.lld: undefined symbol: add
what command are you using to compile
zig build-lib foo.zig
no i mean to compile main.zig
when you compile main.zig you have to add libfoo.a to your list of targets like this: zig build-exe main.zig libfoo.a
Yes, it was stupid of me to forget this
🙂