# Dynamic Library Loading Error

**URL:** <https://ziggit.dev/t/dynamic-library-loading-error/14742>\
**Category:** Help\
**Tags:** standard-library\
**Created:** [March 28, 2026, 3:24pm UTC](https://ziggit.dev/t/dynamic-library-loading-error/14742 "2026-03-28T15:24:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![teiolass](https://ziggit.dev/user_avatar/ziggit.dev/teiolass/32/8157_2.png) [@teiolass](https://ziggit.dev/u/teiolass)\
**Post date:** [March 28, 2026, 3:24pm UTC](https://ziggit.dev/t/dynamic-library-loading-error/14742/1 "2026-03-28T15:24:40Z")

</div>

Hello everyone,

I am a fresh user in the forum, even if I have been using Zig for some years now. I am looking for some pointers to file a bug report (if it’s actually a bug). The problem comes from this simple program:

```zig
const std = @import("std");

pub fn main() !void {
var vk_lib = try std.DynLib.open("libvulkan.so.1");

const Loader = *fn (?*anyopaque, [*:0]const u8) callconv(.c) ?*anyopaque;
const loader = vk_lib.lookup(Loader, "vkGetInstanceProcAddr")
    orelse return error.SymbolNotFound;

std.debug.print("loader: {}\n", .{ loader });

const res = loader(null, "vkCreateInstance");
std.debug.print("res: {*}", .{ res });

}

const spv align(@alignOf(u32)) = @embedFile("shader").*;
const vk = @import("vulkan");

```

When I run it compiling without linking to libc I get a runtime error, while if I link libc everything works fine. I would say there is a problem from the elf loading std.

What should I do?

---

<div class="post-metadata">

**Author:** ![Sze](https://ziggit.dev/user_avatar/ziggit.dev/sze/32/496_2.png) [@Sze](https://ziggit.dev/u/Sze)\
**Post date:** [March 28, 2026, 3:32pm UTC](https://ziggit.dev/t/dynamic-library-loading-error/14742/2 "2026-03-28T15:32:49Z")

</div>

> <https://github.com/ziglang/zig/issues/5360#issuecomment-1256983146>
>
> DynLib fails to open and parse libGL.so un linux (Ubuntu 20.04 x64) due to error….ElfHashTableNotFound. std.elf.readAllHeaders seems to parse the header okay, maybe ElfDynLib should use that.

---

<div class="post-metadata">

**Author:** ![TibboddiT](https://ziggit.dev/user_avatar/ziggit.dev/tibboddit/32/4339_2.png) [@TibboddiT](https://ziggit.dev/u/TibboddiT)\
**Post date:** [March 28, 2026, 9:31pm UTC](https://ziggit.dev/t/dynamic-library-loading-error/14742/3 "2026-03-28T21:31:53Z")

</div>

If you do not want to link libc, but you still want a portable static executable and the ability to load dynamic libraries, you can _try_ [https://github.com/TibboddiT/dyn-loader](https://github.com/TibboddiT/dyn-loader).

There is a [simple example that loads Vulkan](https://github.com/TibboddiT/dyn-loader/blob/main/examples/vulkan_version.zig) in the repo. There is also [a more involved example that draws a triangle using Vulkan](https://github.com/TibboddiT/dyn-loader/blob/main/examples/vulkan_advanced/x11_vulkan_triangle.zig).

If you try it and it does not work, please let me know 🙂
