How to link with C static library ? #18557
-
The documentation explains how to link with C dynamic libraries by using for example:
How to link with a static C library ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I think I found a solution; at least I got the following small example working: // test.c
int test(void) {
return 42;
} // test.h
extern int test(void); Now, I compiled and bound gcc -c -std=c99 -Wall -Werror -Wextra -Wpedantic test.c
ar rs libtest.a test.o To make sure that neither the C file nor its object code would be called from V, I removed both the // test.v
#flag -ltest
#flag -L.
#flag -I .
#include "test.h"
fn C.test() int
fn main() {
println('${C.test()}')
} And finally, I compiled the |
Beta Was this translation helpful? Give feedback.
@leonsal
I think I found a solution; at least I got the following small example working:
Now, I compiled and bound
test.c
as follows:To make sure that neither the C file nor its object code would be called from V, I removed both the
test.c
andtest.o
.And finally, I compiled the
test.v
withv test.v
which gave me the executable./test
; running./test
will print the expectation: 42.