473,388 Members | 1,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Getting path of a shared object from inside it

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

Nov 14 '05 #1
7 1589

On 21/06/2005 14:40, sug wrote:
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" ?

Nov 14 '05 #2

On 21/06/2005 14:40, sug wrote:
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


Nov 14 '05 #3
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

Nov 14 '05 #4

On 21/06/2005 15:01, sug wrote:
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.

Nov 14 '05 #5

On 21/06/2005 15:09, Jean-Claude Arbaut wrote:

On 21/06/2005 15:01, sug wrote:
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.


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

Nov 14 '05 #6
"sug" <za****@yahoo.com> writes:
I need to get the path of my .so from inside it.


[Followup-To: comp.unix.aix set since this is OS specific and has
nothing to do with solaris or c.l.c]

Call loadquery(L_GETINFO, ...)
http://publib16.boulder.ibm.com/pser.../loadquery.htm

Interpreting the result from loadquery() is a bit tricky. You'll
find sample code here:
http://groups-beta.google.com/group/...cb479c1e8440c4

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
Nov 14 '05 #7
Jean-Claude Arbaut wrote:
On 21/06/2005 15:09, Jean-Claude Arbaut wrote:
On 21/06/2005 15:01, sug wrote:
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")?


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.


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:
news:news.announce.newusers
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
Nov 14 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

31
by: John Roth | last post by:
I'm adding a thread for comments on Gerrit Holl's pre-pep, which can be found here: http://tinyurl.com/2578q Frankly, I like the idea. It's about time that all of the file and directory stuff...
2
by: Vincenzo Davi | last post by:
I have created a dll with several classes in C#. One of the classes references image files in the subdirectories of the bin/Release folder (basically where the dll resides). Now, I want to use...
1
by: tshad | last post by:
I just put this together from O'Reillys book (with much of the code stripped out). Global.asax: ****************************************** <%@ Application Language="VB" %> <script...
8
by: bryan | last post by:
Is there any way I can get the application path (the one returned by Request.ApplicationPath) in the Application_Start method in Global.asax? Request is not valid there. On a related note, is there...
7
by: Hitesh | last post by:
Hi, I have a small script here that goes to inside dir and sorts the file by create date. I can return the create date but I don't know how to find the name of that file... I need file that is...
5
by: Tom | last post by:
I have a function that restricts access to a page to logged in users. When a user who isn't logged in goes to the page, it will dynamically generate a login form. I'm trying to use it in...
4
by: Dave | last post by:
The below code is what I'm using to upload JPG's to a Shared folder on my web server. The folder \\GLSDBS03\Entry$ is outside my Web folder. When using FileUpload, and trying to save the JPG, I...
0
by: buntyindia | last post by:
Hi, I have a very strange problem with my application. I have developed it using Struts. I have a TextBox With Some fixed value in it and on Submit iam passing it to another page. <html:form...
8
by: moondaddy | last post by:
I'm posting code for a user control ( FunctionConnectorSelector) below which has 3 content controls in it. each content control uses a style from a resource dictionary merged into the app.xaml...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.