0

Update

I was being foolish - I had a check to see if the file existed (in the same folder) before passing it to dlopen().. so the question is not valid, I will close it.

Original Question

For an exectuable that needs to link to a bunch of shared libraries in a different folder you can just do export LD_LIBRARY_PATH=/some/other/folder and then when you run your exectuable it can find them - and that is all working as expected for me.

However one of my applications uses dlopen() to open a shared library at runtime (in a plug-in like way). I am using dlopen("libsome_lilb.so", RTLD_NOW).

So, this works if the plugin shared lib is in the same folder, but not if its in some other folder. So then I set LD_LIBRARY_PATH and re-try, but it still fails to find the library.

This is related to this question: c-linux-dlopen-cant-find-so-library

But that OP seems to have a varaition of this issue where they are trying to open a .so in the same folder... so I can't see a solution there.

Not quite sure what to tinker with now... maybe some of the options for dlopen("name", options);? (that's a guess)

code_fodder
  • 15,263
  • 17
  • 90
  • 167
  • maybe your program has setuid or setgid? This prevents it from using `LD_LIBRARY_PATH` – bartop Apr 10 '19 at 12:35
  • @bartop I have not intentionally set that - I am guessing I would know if I had done this? My makefile is fairly simple, I don't see any such option... – code_fodder Apr 10 '19 at 12:37
  • for the sake of ruling out obvious problems - just check it with `ls -l` and maybe extend question with the info – bartop Apr 10 '19 at 12:40
  • The man page of dlopen specifies where it searches. – stark Apr 10 '19 at 12:54
  • What does `dlerror()` return? – yugr Apr 10 '19 at 12:59
  • @yugr ...ummmm, sorry - its my crap code ... I was checking if the file exists (in the same dir) before passing it to `dlopen()`. So I was not seeing me dlerror() output. I only noticed this when I went to look why as a result of your question and spotting my error. It works fine now... feel free to write your comment as an answer and I can mark it up - I will edit my question to reflect my foolishness :o - and then I wil close my question – code_fodder Apr 10 '19 at 13:46

0 Answers0