Thread: how to obtain the absolute application path

  1. #1
    Registered User
    Join Date
    Nov 2001

    how to obtain the absolute application path

    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

  2. #2
    ... kermit's Avatar
    Join Date
    Jan 2003
    so the program runs when you click the icon or not?

  3. #3
    Registered User
    Join Date
    Nov 2001
    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.

  4. #4
    Me -=SoKrA=-'s Avatar
    Join Date
    Oct 2002
    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.
    SoKrA-BTS "Judge not the program I made, but the one I've yet to code"
    I say what I say, I mean what I mean.
    IDE: emacs + make + gcc and proud of it.

  5. #5
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003

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


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. get application data folder path
    By skuallpa in forum C++ Programming
    Replies: 4
    Last Post: 06-12-2009, 03:19 PM
  2. How to judge whether a path is relative or absolute?
    By bbebfe in forum C Programming
    Replies: 2
    Last Post: 11-16-2008, 03:23 AM
  3. Obtain Cd-Rom path and one more
    By ch4 in forum Windows Programming
    Replies: 4
    Last Post: 09-14-2007, 04:23 AM
  4. Replies: 1
    Last Post: 03-02-2006, 01:01 AM
  5. Application path
    By zigona in forum C++ Programming
    Replies: 4
    Last Post: 11-18-2001, 04:37 PM