autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: finding datadir from executable


From: Bob Friesenhahn
Subject: Re: finding datadir from executable
Date: Sat, 11 Sep 2004 12:00:38 -0500 (CDT)

On Sat, 11 Sep 2004, Ralph Corderoy wrote:

You give it argv[0], BINDIR, and OTHERDIR; it computes the relative
path between bindir and otherdir, finds your application in $PATH or
similar, and works out the likely location of otherdir.

Does argv[0] always contain a path on all Unixes?  IIRC, some old ones
put just `ls' there despite execve(2) being given "/bin/ls".

In my experience argv[0] does not always contain a full path. It generally contains whatever was used to execute the program. For example it could contain "../foo/bar". Usually if the program was executed via the executable search path, it contains a full path. If your application is compiled under Windows (e.g. MinGW), you can expect more interesting issues since the path may include drive letters or SMB \\ prefixes. Windows and Solaris provide function calls which return the path to the executable directly without use of argv[0].

The burden is on the programmer to figure things out within their application and therefore this issue is not an Autoconf-related topic.

Bob
======================================
Bob Friesenhahn
address@hidden
http://www.simplesystems.org/users/bfriesen




reply via email to

[Prev in Thread] Current Thread [Next in Thread]