DllImport Troubles
Hello there. I'm running on linux. I'm trying to load symbols from a library named
libxyz.so
. I have written it as such:
however, I get this runtime error:
I used the LD_DEBUG
environment variable as instructed, and discovered that while the runtime is correctly identifying the possible permutations (xyz
, libxyz
, xyz.so
, libxyz.so
) it is only searching for those permutations in the system search path (i.e. /usr/lib
) and nowhere else. That is to say, it is not searching the current directory, which is where the file is located. How can I remedy this?15 Replies
please ping on response
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
i don't use IDEs
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
i'll look up the relevant fields of *.csproj
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
hmm.
i don't see any relevant msbuild properties
wait
MS documentation be good challenge
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
there are no relevant MSBuild properties that change this behavior
hmm. i still can't get it working
this didn't solve it
how should i resolve it?
well, i don't know why it isn't working--i don't know too many specifics about the dynamic linker on linux. the behavior is pretty standard. if you try
NativeLibrary.Load("libxyz.so")
and it still doesn't work, that is directly equivalent to dlopen("libxyz.so", RTLD_LAZY)
. so whatever fixes that would fix thisthis might be a somewhat naive thing to say but i am pretty sure
dlopen
doesn't search the current directory by default https://linux.die.net/man/3/dlopendlopen(3) - Linux man page
dlopen() The function dlopen() loads the dynamic library file named by the null-terminated string filename and returns an opaque "handle" for the dynamic library.
hmm
ok i got it to work
the path needs to contain a
/
to be treated as a path
otherwise it looks for it in the system librariesUnknown User•3y ago
Message Not Public
Sign In & Join Server To View
unfortunately this means it's not cross-platform. so
#if
and friends need to be used
but that's ok
figured it out methinks