View Full Version : how to obtain the absolute application path

12-23-2004, 10:48 AM
hi, I've nearly accomplished a small QT app that makes ballistic calculations for small arms, draws graphics, prints charts, has multilanguage support and all the usual stuff. But , since I Am The Real Dumbass Newbie I am getting crazy with a really silly problem: I have to find the path where my application is, I've tried argv[0], I've messed with char *realpath and getcwd, but I always keep getting stuck into my home (like in real life...) the question is: when I launch the app from a shell window,

[jagerhans@shangri-la jagerhans]$ cd qtballit
[jagerhans@shangri-la qtballit]$ ./Qtballit

everything runs fine, but if I simply click the app icon, the app only knows that the cwd is my home and *not* /somedirectory/strangepath/puppa/qtballit/ and therefore isn't able to find the language files, the html manpage, etc.

is there something like $0 in bash?

thanks a lot

12-23-2004, 11:17 AM
so the program runs when you click the icon or not?

12-23-2004, 11:49 AM
Yes, it runs fine, but with some limitation: since it cannot find the language files and the manual pages the application cannot translate its labels into german (the language I was asked for) and the browser pops up with an error message (cannot find xxx.html) when one asks for the manual.

12-23-2004, 02:52 PM
The reason it works on your command line is because the working directory happens to be the same one as the app's directory. Can't you do some sort of 'shortcut' and set the working dir to the dir the app needs? Sorry for not trying it out myself, but I can't get a GUI on this machine.

12-23-2004, 05:48 PM

Last post, 4th paragraph - "The most common..."