Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

Commit

Permalink
imp - Set LD_LIBRARY_PATH
Browse files Browse the repository at this point in the history
---

We need to set LD_LIBRARY_PATH.

---

Type: imp
Breaking: False
Doc Required: False
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Jul 11, 2024
1 parent 0b71e48 commit f346a59
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions NativeLand/LibraryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ internal void LoadLibraries(LibraryItem item)
internal void LoadNixLibrary(string path)
{
_logger?.LogInformation($"Calling dlopen for {path}");
string folder = Path.GetDirectoryName(path);
int pathResult = setenv("LD_LIBRARY_PATH", $":{folder}", 0);
if (pathResult != 0)
throw new Exception("Unable to set LD_LIBRARY_PATH");
try
{
var result = dlopen(path, RTLD_LAZY | RTLD_GLOBAL);
Expand Down Expand Up @@ -139,6 +143,12 @@ internal void LoadWindowsLibrary(string path)

[DllImport("libdl.so.2", EntryPoint = "dlopen")]
private static extern IntPtr dlopen_new(string file, int mode);

/// <summary>
/// int setenv(const char *name, const char *value, int overwrite);
/// </summary>
[DllImport("libc", CharSet = CharSet.Ansi)]
internal static extern int setenv(string name, string value, int overwrite);
#endregion

#region LoadLibraryEx
Expand Down

0 comments on commit f346a59

Please sign in to comment.