dotnet/runtime · error

Option : missing shared library path

Error message

Option %s: missing shared library path

What it means

Printed at src/coreclr/hosts/corerun/corerun.cpp:818 when -l/--preload is given but no shared library path follows (i>=argc). The preload option needs a library file to dlopen before initializing the CLR.

Solutions

  1. Provide the full path to the shared library after -l.
  2. Verify the variable holding the library path is set and the file exists.
  3. Ensure the library matches the corerun architecture (64-bit library for 64-bit host).

Example fix

# before
corerun -l MyApp.dll
# after
corerun -l /usr/lib/libmyhook.so MyApp.dll
Defensive patterns

Strategy: validation

Validate before calling

// Ensure -l/--preload is followed by an existing library path
#include <filesystem>
bool preload_ok(int argc, char** argv) {
    for (int i=1;i<argc;i++) {
        if (!strcmp(argv[i],"-l") || !strcmp(argv[i],"--preload")) {
            if (i+1>=argc) return false;
            if (!std::filesystem::exists(argv[i+1])) return false;
        }
    }
    return true;
}

Prevention

When it happens

Trigger: Triggered when `corerun -l` / `corerun --preload` is the final argument with no library path after it.

Common situations: A script passes an empty $LIB variable, or the user forgets the path while trying to set up a profiling/debugging hook library.

Related errors


AI-assisted analysis of dotnet/runtime@60108ba66e (2026-08-10). Data as JSON: /api/errors/303ff130efa9326d. Report an issue: GitHub.

Appendix: source

Thrown at src/coreclr/hosts/corerun/corerun.cpp:818

            string_t prop = argv[i];
            size_t delim_maybe = prop.find(W('='));
            if (delim_maybe == string_t::npos)
            {
                pal::fprintf(stderr, W("Option %s: '%s' missing property value\n"), arg, prop.c_str());
                break;
            }

            string_t key = prop.substr(0, delim_maybe);
            string_t value = prop.substr(delim_maybe + 1);
            config.user_defined_keys.push_back(std::move(key));
            config.user_defined_values.push_back(std::move(value));
        }
        else if (pal::strcmp(option, W("l")) == 0 || (pal::strcmp(option, W("preload")) == 0))
        {
            i++;
            if (i >= argc)
            {
                pal::fprintf(stderr, W("Option %s: missing shared library path\n"), arg);
                break;
            }

            string_t library = argv[i];
            pal::mod_t hMod;
            if (!pal::try_load_library(library, hMod))
            {
                break;
            }
        }
        else if (pal::strcmp(option, W("d")) == 0 || (pal::strcmp(option, W("debug")) == 0))
        {
            config.wait_to_debug = true;
        }
        else if (pal::strcmp(option, W("st")) == 0)
        {
            config.self_test = true;
            return true;

View on GitHub (pinned to 60108ba66e)