# Building a C(++) dependency with zig that requires the install directory path at configure time

**URL:** <https://ziggit.dev/t/building-a-c-dependency-with-zig-that-requires-the-install-directory-path-at-configure-time/18113>\
**Category:** Help\
**Tags:** c, build-system\
**Created:** [October 27, 2026, 10:47am UTC](https://ziggit.dev/t/building-a-c-dependency-with-zig-that-requires-the-install-directory-path-at-configure-time/18113 "2026-10-27T10:47:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![smups](https://ziggit.dev/user_avatar/ziggit.dev/smups/32/3131_2.png) [@smups](https://ziggit.dev/u/smups)\
**Post date:** [October 27, 2026, 10:47am UTC](https://ziggit.dev/t/building-a-c-dependency-with-zig-that-requires-the-install-directory-path-at-configure-time/18113/1 "2026-10-27T10:47:29Z")

</div>

Hi all!

I’m going through the process of updating my zig scripts to build a C++ project that depends on a bunch of libraries including [LHAPDF](https://www.lhapdf.org/), a physics library providing Parton Distribution Functions (PDFs). PDFs don’t have closed forms and are stored as numerical data that the library turns into a callable functions. The PDF data (to be installed separately from the library when needed) is stored in a hard-coded directory specified at build-time by a C macro.

In my 0.16 build script, I simply used:

```zig
const data_prefix = b.fmt("\"{s}/share\"", .{b.install_prefix});
lhapdf.addCMacro("LHAPDF_DATA_PREFIX", data_prefix);

// (...)

// Setup share directory
const temp_ddir = b.addNamedWriteFiles("share");
_ = temp_ddir.addCopyFile(upstream.path("lhapdf.conf"), "lhapdf.conf");
_ = temp_ddir.addCopyFile(upstream.path("pdfsets.index"), "pdfsets.index");

b.installArtifact(liblhapdf);
b.installDirectory(.{
    .install_dir = .{ .custom = "share" },
    .install_subdir = "LHAPDF",
    .source_dir = temp_ddir.getDirectory(),
});

```

However, I learned that in 0.17 the Make and Configure steps were separated and things such as `b.install_prefix` are no longer available. According to Claude, in 0.17, there is no longer a way to get the installation directory as a string at configure-time. However, `LHAPDF_DATA_PREFIX` really has to point to the correct place otherwise the library does not work!

I figured I’d ask if there is an intended path for such a use-case in 0.17 before I try to come up with an ugly work-around 😛

---

<div class="post-metadata">

**Author:** ![matklad](https://ziggit.dev/user_avatar/ziggit.dev/matklad/32/2462_2.png) [@matklad](https://ziggit.dev/u/matklad)\
**Post date:** [October 27, 2026, 11:35am UTC](https://ziggit.dev/t/building-a-c-dependency-with-zig-that-requires-the-install-directory-path-at-configure-time/18113/2 "2026-10-27T11:35:33Z")

</div>

See [https://codeberg.org/ziglang/zig/issues/37124](https://codeberg.org/ziglang/zig/issues/37124)

---

<div class="post-metadata">

**Author:** ![smups](https://ziggit.dev/user_avatar/ziggit.dev/smups/32/3131_2.png) [@smups](https://ziggit.dev/u/smups)\
**Post date:** [October 27, 2026, 12:40pm UTC](https://ziggit.dev/t/building-a-c-dependency-with-zig-that-requires-the-install-directory-path-at-configure-time/18113/3 "2026-10-27T12:40:36Z")

</div>

Ah great that does indeed cover my use case 🙂 I’ll wait until the next 0.17.1 before upgrading.
