diff --git a/doc/langref.html.in b/doc/langref.html.in index f552d3456770755b338b8b660df3ca7f7eb712bd..9373c3bcc884778ab4771a1e1553b0e015fb6ab5 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -8859,20 +8859,21 @@ export fn add(a: i32, b: i32) i32 { return a + b; } {#code_end#} -

To make a shared library:

-
$ zig build-lib mathtest.zig
-

To make a static library:

-
$ zig build-lib mathtest.zig --static
+      
$ zig build-lib mathtest.zig
+
+

To make a shared library:

+
$ zig build-lib mathtest.zig -dynamic
 

Here is an example with the {#link|Zig Build System#}:

test.c

// This header is generated by zig from mathtest.zig
 #include "mathtest.h"
-#include <assert.h>
+#include <stdio.h>
 
 int main(int argc, char **argv) {
-    assert(add(42, 1337) == 1379);
+    int32_t result = add(42, 1337);
+    printf("%d\n", result);
     return 0;
 }

build.zig

@@ -8882,10 +8883,10 @@ const Builder = @import("std").build.Builder; pub fn build(b: *Builder) void { const lib = b.addSharedLibrary("mathtest", "mathtest.zig", b.version(1, 0, 0)); - const exe = b.addCExecutable("test"); - exe.addCompileFlags([][]const u8{"-std=c99"}); - exe.addSourceFile("test.c"); + const exe = b.addExecutable("test", null); + exe.addCSourceFile("test.c", [][]const u8{"-std=c99"}); exe.linkLibrary(lib); + exe.linkSystemLibrary("c"); b.default_step.dependOn(&exe.step); @@ -8896,10 +8897,9 @@ pub fn build(b: *Builder) void { } {#code_end#}

terminal

-
$ zig build
-$ ./test
-$ echo $?
-0
+
$ zig build test
+1379
+
{#see_also|export#} {#header_close#} {#header_open|Mixing Object Files#}