Re: Executing program from its path



On Sun, Oct 22, 2006 at 01:39:01PM +0200, Lorenzo Marcon wrote:
My program create pixmaps loading images from files located in a subfolder of the executable.
Under windows, I have no problem.
Under Linux, I'm experiecing the following inconvenient:

Don't do that then[*].  Install binaries to ${prefix}/bin,
pixmaps to ${prefix}/share/APPNAME (or to appropriate icon
theme directory) where prefix is specified compile-time as
usual.  If you want the app relocatable, let an environment
variable override the location the app looks for its data
files.

[*] If your program is something that could be eventually
packaged for GNU/Linux distros, note the packagers will
1. hate you 2. change the installation style to the standard
one.

Can I handle this inside the program in any way?

Unless the user creates a hardlink to the executable, which
makes finding the original location essentially impossible,
one can resolve relative paths to absolute, try to find self
in $PATH and resolve symlinks (or to use an OS-specific
trick like looking into /proc/MYPID) to find self, but since
I'm trying to discourage you from doing this I won't give
the details.

Yeti


--
Whatever.



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