Skip to content

make the CLI support depending on system headers and libraries (include and lib search paths) #2041

@Akuli

Description

@Akuli

On my system, @cImport(@cInclude("stdio.h")) works, but @cImport(@cInclude("gmp.h")) doesn't. gmp.h is in /usr/include/x86_64-linux-gnu, and stdio.h is in /usr/include. I'm running a simple test file with zig test filename.zig --library gmp --library c:

// run with:  zig test filename.zig --library gmp --library c
const gmp = @cImport(@cInclude("gmp.h"));

test "asdasd" {
    var num: gmp.mpz_t = undefined;
    gmp.mpz_init_set_ui(&num[0], 123);
    defer gmp.mpz_clear(&num[0]);
    _ = gmp.gmp_printf(c"'%Zd' should be '-123'\n", &num[0]);
}

This worked in 0.3.0+9c5852aa, but is broken in 0.3.0+0a8a7a57. On this system, zig is cloned to ~/sourcestuff/zig and built there, then bin and lib are copied to ~/zig/ (~/zig/bin is in $PATH).

Metadata

Metadata

Assignees

No one assigned

    Labels

    contributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.enhancementSolving this issue will likely involve adding new logic or components to the codebase.frontendTokenization, parsing, AstGen, Sema, and Liveness.stage1The process of building from source via WebAssembly and the C backend.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions