LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Obtain the path of a libarary from C source (http://www.linuxquestions.org/questions/programming-9/obtain-the-path-of-a-libarary-from-c-source-4175432278/)

littleplane 10-15-2012 06:33 AM

Obtain the path of a libarary from C source
 
My problem is how to obtain the installation place of a library on linux and do it from C source. E.g. I want to know where is libresolv.so placed. To be more tricky I cannot use system calls to run shell (that is no ldconfig, no pkconfig, etc.)

Snark1994 10-15-2012 07:38 AM

Can you not use 'find' or 'locate'? As far as I know (and that's not necessarily very far) the time it needs libresolv.so is when it's compiling the source - so the information would not be present in the source code, but instead in the command you used to compile the source (or in the system path, which you can obtain by running 'echo $PATH')

NevemTeve 10-15-2012 07:55 AM

Why do you have to know, by the way?

littleplane 10-15-2012 08:36 AM

Quote:

Originally Posted by NevemTeve (Post 4806104)
Why do you have to know, by the way?

I'm working on a program what "chroots" a process. This process uses such shared libraries like libresolv.so, libssl.so, libcrypto.so, etc. and I need to hard link/copy them into my sandbox environment. Unfortunatelly due to some coding requirements I must not use any "shell things", so locate and find aren't possible solutions now :(

NevemTeve 10-15-2012 09:08 AM

ldd(1) is your friend

littleplane 10-15-2012 09:34 AM

Quote:

Originally Posted by NevemTeve (Post 4806154)
ldd(1) is your friend

ldd is neither a possible way because it only lists the static but not the dynamic dependencies, that is what are loaded with dlopen().


All times are GMT -5. The time now is 07:12 AM.