Hi,
I work with a Yocto based project(Kirkstone) and I typically use the toolchain generated with it. So far I have tried to build standalone small zig programs compiled with zig build system and the integrated libC. I wonder however if there is an specific way to configure build system to use my toolchain rootfs file system and compile against these dynamic system libraries.
Is there any tutorial or additional information what to use in order to compile against my own system libraries?
I tried to compile a simple wayland C++ program which uses egl as this but it is failing:
const std = @import("std");
pub fn build(b: *std.build.Builder) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// DTC Binary
const egl = b.addExecutable(.{
.name = "egl",
.target = target,
.optimize = optimize,
});
egl.linkLibCpp();
egl.addLibraryPath(.{ .path = "/opt/4.0.10-toolchain/sysroots/aarch64-poky-linux/usr/lib/" });
egl.addSystemIncludePath(.{ .path = "/opt/4.0.10--toolchain/sysroots/aarch64-poky-linux/usr/include/" });
egl.linkSystemLibrary("wayland-egl");
egl.linkSystemLibrary("wayland-client");
egl.linkSystemLibrary("EGL");
egl.linkSystemLibrary("GLESv2");
egl.addCSourceFiles(&.{
"egl_render.cpp",
}, &.{
"-std=c++17",
"-fno-rtti",
"-fno-exceptions",
});
b.installArtifact(egl);
}
I build with
zig build -Dtarget=aarch64-linux-gnu
At this moment, I am able to build with these instructions, however, I’m wondering at this moment if this is the right configuration for this kind of setup.
Is there a better way of doing it?
At the moment, I am having some segmentation fault error that I still need to investigate, I will post when I have time to make some debugging.
Thanks for any feedback