473,473 Members | 1,477 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to get the absolute path of the library currently loaded?

Hi,

I was wondering if there was a way to know the absolute path of the
library "currently running".
For example, in my function foo, how can I get the path of the library
containing the definition of foo?

The library path will be different from the "current directory" (.)
since the current directory will be the directpry of the prgram that
loaded the lib; not the path to the library itself.

Otherwise, do you know fi the STL library provide a "registry service"
(like the java Preferences API)?

Thanks a lot for your help

May 3 '06 #1
4 5453
br***********@gmail.com wrote:
Hi,

I was wondering if there was a way to know the absolute path of the
library "currently running".
For example, in my function foo, how can I get the path of the library
containing the definition of foo?

The library path will be different from the "current directory" (.)
since the current directory will be the directpry of the prgram that
loaded the lib; not the path to the library itself.
That's very platform specific, some platforms might not even have
libraries or directories.

Better ask on a group specific to your platform.
Otherwise, do you know fi the STL library provide a "registry service"
(like the java Preferences API)?

No.

--
Ian Collins.
May 3 '06 #2
br***********@gmail.com wrote:
I was wondering if there was a way to know the absolute path of the
library "currently running".
There can be. However, it would be a feature of the OS, not of the
language.
In C++ what's "running" is the program, not "the library". The host system
_may_ provide the command with which it was started, in the 'argv[0]' (see
the 'main' function), or it may not, it's up to the system. Many systems
do,
yet some don't.
For example, in my function foo, how can I get the path of the library
containing the definition of foo?
C++ defines the _language_. In C++ you can find the _translation unit_ in
which the *code* is contained (see __FILE__ macro). The rest is platform-
and implementation-specific (and off-topic here).
The library path will be different from the "current directory" (.)
since the current directory will be the directpry of the prgram that
loaded the lib; not the path to the library itself.
All those things are unknown to C++.
Otherwise, do you know fi the STL library provide a "registry service"
(like the java Preferences API)?


Nothing like that in the Standard.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
May 3 '06 #3
> I was wondering if there was a way to know the absolute path of the
library "currently running".
For example, in my function foo, how can I get the path of the library
containing the definition of foo?


on unix : ldd ./a.out (./a.out is the executable )
macosX : oTool ./a.out

regards,
Aman Angrish.
--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
May 3 '06 #4
br***********@gmail.com wrote:
Hi,

I was wondering if there was a way to know the absolute path of the
library "currently running".
For example, in my function foo, how can I get the path of the library
containing the definition of foo?

The library path will be different from the "current directory" (.)
since the current directory will be the directpry of the prgram that
loaded the lib; not the path to the library itself.

Otherwise, do you know fi the STL library provide a "registry service"
(like the java Preferences API)?

Thanks a lot for your help

In unix type the following command :
$ ldd <executable name>

If you want to attach the libraries at the time of running, you have
update the LD_LIBRARY_PATH
Regards,

Thobias Vakayil

May 3 '06 #5

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

Similar topics

3
by: Peter Taurins | last post by:
Hi there. I have an included file (header.php) that contanis a reference to a graphic. If I stay at the root level, then I can control the relative path of the image. eg. images/imagename.jpg ...
4
by: dchaffin | last post by:
I'm having a problem using file_exists with an absolute path and I can not figure out why. I tried the exact example that is on www.php.net ... <?php $filename = '/path/to/foo.txt'; if...
8
by: Fu Bo Xia | last post by:
the java.lang.Object.forName method takes a java class name and returns a Class object associated with that class. eg. Class myClass = Object.forName("java.lang.String"); by if i only know the...
9
by: Stuart | last post by:
Hi All, I got a challenge to make the same APS/Script/Html run on different web roots. I can not use relative pathing in a lot of cases. We use lots of included files so depending on where that...
2
by: mhadi | last post by:
Hi All, I am developing a solutions for clients to run some webpages. Since there is no webserver the ASP route is a No Go. So I am using Javascript to connect to my database. The Problem is that...
6
by: Jon Slaughter | last post by:
do I have to prefix every absolute path with document root to get it to work? For some reason I thought that prefixing a path with '/' or './' with make it absolute w.r.t to document root but I...
11
by: cybervigilante | last post by:
I can't seem to change the include path on my local winmachine no matter what I do. It comes up as includ_path .;C:\php5\pear in phpinfo() but there is no such file. I installed the WAMP package...
1
by: Maanav Jackson | last post by:
Hi I am displaying a third party webpage into a variable using curl library. When i am displaying the variable in the browser using echo command as shown below. echo $pagecopy; Browser is...
13
by: Nathan Sokalski | last post by:
I have a page in my site that I need the absolute url of. Is there a function in .NET to which you can pass a relative url or something such as "~/mydirectory/mypage.aspx" which will return an...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.