Lyricdev
GitHub

LYR-BLD0006

a file the build puts beside the binary is not there, shares its name, or would not be found there

error · spec 15-project

Reported when a package's build.lyr names a file with std.build.besideBinary that is not there when the script has ended, when two such files — or dylibs of the native part — have one name, or when a library of dylibs would not be found there — a Mach-O library whose install name does not begin with @rpath/, an ELF library without a soname. Nothing is built; the exit code is 1.

Explanation

build.besideBinary(path) asks the build to copy a file into the directory of every binary it makes of the program — a shared library the program loads when it starts, most of all, such as SDL3.dll beside app.exe. The binary looks for shared libraries in its own directory first, so the program starts from wherever it is copied, with the library beside it. The copy goes under the file's own name, so the file must be there when the script ends, and two files with one name — from two packages, or from two directories — would overwrite each other.

A path relative to the package's root is read from there; one from the environment (SDL3_DIR) is likely wrong where it is missing. Name the variable with build.rerunIfEnvChanged, so the script runs again when it is set right, and check that the file is there before naming it: build.warn can say what to set.

The library's own directory goes to the link with build.linkSearch(dir), which is never written into the binary: the program does not depend on where the build found it.

The shared libraries a package names in dylibs lie beside the binary too, under the same rule: no two files of one name. And the binary finds such a library there only by the name the library gives itself. A Mach-O library must call itself @rpath/libfoo.dylib — install_name_tool -id @rpath/libfoo.dylib libfoo.dylib renames one —, an ELF library must have a soname — patchelf --set-soname libfoo.so libfoo.so, or -Wl,-soname,libfoo.so where you build it. Without one, the binary would record the path the library was linked from, a path of the machine that built it.

Wrong

//- build.lyr
import std.build;

fn main(): void {
    build.besideBinary("lib/missing.dll");
}
//- src/main.lyr
fn main(): void {
}
//- build.lyr
import std.build;

fn main(): void {
    build.besideBinary("data/notes.txt");
}
//- data/notes.txt
beside the binary
//- src/main.lyr
fn main(): void {
}