Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting environment variable (LD_LIBRARY_PATH) for mono, rather than the program run #84

Open
copygirl opened this issue Dec 19, 2021 · 0 comments

Comments

@copygirl
Copy link

I'm helping out with an indie game which is built on .NET 4.6.1 and is trying its best to support Linux. Recently I found out that native libraries that were available for different architectures, and therefore stored in two different folders Lib32 and Lib64, were not able to be loaded from these paths.

In #monovm on the DotNetEvolution Discord I was recommended to use LD_LIBRARY_PATH to specify which of the folders to load libraries from. This works well when I change the game's launch script:

if [ $(uname -m) == 'x86_64' ]; then ARCH=64; else ARCH=32; fi
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/share/<game>/Lib$ARCH
exec /usr/bin/mono /usr/share/<game>/<executable>.exe

However, when trying to do something similar in the launch.json, the game still fails to find the library.

{
  "version": "0.2.0",
  "configurations": [{
    "name": "Launch Client (Mono)",
    "type": "mono",
    "request": "launch",
    "preLaunchTask": "build",
    "program": "${workspaceRoot}/bin/Debug/<executable>.exe",
    "cwd": "${workspaceRoot}/bin/Debug",
    "env": { "LD_LIBRARY_PATH": "${env:LD_LIBRARY_PATH}:${workspaceRoot}/bin/Debug/lib64" }
  }]
}

I can confirm using Environment.GetEnvironmentVariable that the variable has been set correctly, but it appears that this environment variable is only set in the context of the program itself, rather than the mono binary, which (from my understanding) in charge of loading native libraries.

Is it possible to pass environment variables to the mono executable itself when debugging?

(Note: In the released game, the library folder is called "Lib64", while when debugging from source, it's "lib64", so in case you noticed that, it's not actually a typo, just a bit of an odd decision from the core developers who develop on Windows.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant