I’m trying to use the allyourcodebase package of box2d to build a wasm32 static library that emscripten can link to when building my main project (that is written in C).
this is the command I’m running:
git clone https://github.com/allyourcodebase/box2d
cd box2d
cat >build.zig <<EOF
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const box2d_dep = b.dependency("box2d", .{});
const lib = b.addStaticLibrary(.{
.name = "box2d",
.target = target,
.optimize = optimize,
});
lib.linkLibC();
lib.addIncludePath(box2d_dep.path("include"));
lib.installHeadersDirectory(box2d_dep.path("include"), "", .{});
lib.addCSourceFiles(.{
.root = box2d_dep.path("src"),
.flags = &.{
"-std=c17",
},
.files = &.{
"aabb.c",
"array.c",
"bitset.c",
"body.c",
"broad_phase.c",
"constraint_graph.c",
"contact.c",
"contact_solver.c",
"core.c",
"distance.c",
"distance_joint.c",
"dynamic_tree.c",
"geometry.c",
"hull.c",
"id_pool.c",
"island.c",
"joint.c",
"manifold.c",
"math_functions.c",
"motor_joint.c",
"mouse_joint.c",
"prismatic_joint.c",
"revolute_joint.c",
"shape.c",
"solver.c",
"solver_set.c",
"stack_allocator.c",
"table.c",
"timer.c",
"types.c",
"weld_joint.c",
"wheel_joint.c",
"world.c",
},
});
b.installArtifact(lib);
}
EOF
zig build -Dtarget=wasm32-emscripten
which produces the error:
install
└─ install box2d
└─ zig build-lib box2d Debug wasm32-freestanding 32 errors
/Users/daniel/.cache/zig/p/1220c6750412ebc698694cd08aca4fe87fda8e2df0d4ffa7d33e7de5b8ca5bebb643/include/box2d/math_functions.h:9:10: error: 'math.h' file not found
#include <math.h>
^~~~~~~~~
/Users/daniel/.cache/zig/p/1220c6750412ebc698694cd08aca4fe87fda8e2df0d4ffa7d33e7de5b8ca5bebb643/src/math_functions.c:4:10: note: in file included from /Users/daniel/.cache/zig/p/1220c6750412ebc698694cd08aca4fe87fda8e2df0d4ffa7d33e7de5b8ca5bebb643/src/math_functions.c:4:
#include "box2d/math_functions.h"
Any ideas how to get a wasm32 library built of box2d?