Wgpu-native library location confusion

Hi

Sorry if this question has already been asked but I have been unable to find a suitable answer here, and the various LLMs are also being utterly useless

I would like to use wgpu-native in a project but the only way I can get Odin (the compiler) to see the libraries is when I place them into Odin’s vendor directory directly, I cannot get them to be read from the project directory at all. Ideally I would like to avoid having to place the libraries into Odin’s vendor directory in every build environment

Is it possible to keep the wgpu-native libraries in my project directory but continue to statically link them so the source code ends up in my compiled executable?

The error I am getting when the libraries are not placed in Odin’s vendor directory is:

Error: Compile time panic: Could not find the compiled WGPU Native library at '/opt/homebrew/Cellar/odin/2026-02/libexec/vendor/wgpu/lib/wgpu-macos-aarch64-debug/lib/libwgpu_native.a'

I do have the correct libraries downloaded, if I move them into Odin’s vendor/wgpu directory everything works as expected

Thanks for any help

This may not be the right answer.

Copy .so library file to local project folder
Add to project:

foreign import fileso "file.so"

To see that paths used by linker, use ldd
run command

ldd <executable_name>

Update: This is how I tried it, but note, I have not messed with foreign imports that much in Odin, so someone with more experience may correct me.

I tried with libc. Copied the file from my system directory where it is normally found and placed it in my project folder.

// had to change the reference name for the bindings in core:c/lib because of name collision
// so that I could still use those procedures. Just have to prefix them with "lc" instead.
import lc "core:c/libc"

// then used libc name here, since core:c/libc bindings are defined with
// foreign libc { ... }
foreign import libc "libc.so.6"

ldd output

libc.so.6 => /home/xuul/Documents/projects/odin/sigint/libc.so.6 (0x0000775baae00000)
1 Like

Thanks @xuul I will give your suggestion a try

Maybe a future Odin update will make this less convoluted

If all else fails I can write a few scripts that copy dependencies to the Odin vendor directory