#Issue Importing C Library

1 messages · Page 1 of 1 (latest)

nova cypress
#

I am trying to import code from the WINGs C library. However, it doesn't seem to work. In vscode the code autofills, and it is definitely installed, it simply doesn't work. The error reads:

error: ld.lld: undefined symbol: WMInitializeApplication
    note: referenced by main.zig:16

Code:

const std = @import("std");
const c = @cImport({
    @cInclude("WINGs/WINGs.h");
});

pub fn main() !void {
    var gpa = std.heap.GeneralPurposeAllocator(.{}){};
    const allocator = gpa.allocator();
    defer _ = gpa.deinit();

    const args = try std.process.argsAlloc(allocator);
    defer std.process.argsFree(allocator, args);

    const cFriendlyArgs = @ptrCast([*c][*c]u8, args);

    c.WMInitializeApplication("Volume Control", args.len, cFriendlyArgs);
    var display = c.XOpenDisplay("");
    var defaultScreen = c.DefaultScreen(display);
    var screen = c.WMCreateScreen(display, defaultScreen);
    var win = c.WMCreateWindow(screen, "");

    c.WMRealizeWidget(win);
    c.WMMapWidget(win);
    c.WMScreenMainLoop(screen);
}
nova cypress
#

Update: Importing doesn't work in C either. The library must be borked

lyric cave
#

what is the build.zig?

#

are you properly linking the library?

nova cypress