Getting path of a shared object from inside it

S

sug

Hi,

I am running a C program on Unix which loads a shared object of mine.

I need to get the path of my .so from inside it. I want to do this
because from my .so I want to open a text file which is in same
directory as my .so.

getcwd() obviously doesn't serve my purpose because my .so is not in
"cwd" but I am pointing my executable to it using the
LIBPATH/LD_LIBRARY_PATH.

Can somebody provide any pointers? Thanks in advance


Sug
 
J

Jean-Claude Arbaut

Hi,

I am running a C program on Unix which loads a shared object of mine.

I need to get the path of my .so from inside it. I want to do this
because from my .so I want to open a text file which is in same
directory as my .so.

getcwd() obviously doesn't serve my purpose because my .so is not in
"cwd" but I am pointing my executable to it using the
LIBPATH/LD_LIBRARY_PATH.

Can somebody provide any pointers? Thanks in advance


Sug
 
J

Jean-Claude Arbaut

Hi,

I am running a C program on Unix which loads a shared object of mine.

I need to get the path of my .so from inside it. I want to do this
because from my .so I want to open a text file which is in same
directory as my .so.

getcwd() obviously doesn't serve my purpose because my .so is not in
"cwd" but I am pointing my executable to it using the
LIBPATH/LD_LIBRARY_PATH.

Can somebody provide any pointers? Thanks in advance

I think it's implementation dependent. You should have a look at your
dynamic linker documentation. Maybe "man dyld" ?
 
S

sug

Hi Jean,

Thanks. I am not sure but I guess "dyld" is a utility right?
I need to do it from my code, I probably need a function that I can
call from C. Or you were poining at doing system("dyld")?

Thanks, Sug
 
J

Jean-Claude Arbaut

Hi Jean,

Thanks. I am not sure but I guess "dyld" is a utility right?
I need to do it from my code, I probably need a function that I can
call from C. Or you were poining at doing system("dyld")?

Thanks, Sug

No, actually, dyld is the dynamic linker on my platform, I don't know its
name on yours. Basically, it's the program that loads executables and ".so"
files, and it provides functions to access the object "headers", which
provide many important informations. On your platform I suppose there is
something similar.
 
J

Jean-Claude Arbaut

No, actually, dyld is the dynamic linker on my platform, I don't know its
name on yours. Basically, it's the program that loads executables and ".so"
files, and it provides functions to access the object "headers", which
provide many important informations. On your platform I suppose there is
something similar.

To be more explicit: these functions are available in C programs.
 
C

CBFalconer

Jean-Claude Arbaut said:
To be more explicit: these functions are available in C programs.

And, instead of cluttering up c.l.c with 4 or more off-topic
replies, you could have limited yourself to one setting followups
to a more appropriate newsgroup. The fact that the OP failed to do
so is no excuse.

--
Some informative links:
http://www.geocities.com/nnqweb/
http://www.catb.org/~esr/faqs/smart-questions.html
http://www.caliburn.nl/topposting.html
http://www.netmeister.org/news/learn2quote.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top