how to obtain the absolute application path

This is a discussion on how to obtain the absolute application path within the Linux Programming forums, part of the Platform Specific Boards category; hi, I've nearly accomplished a small QT app that makes ballistic calculations for small arms, draws graphics, prints charts, has ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    7

    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
    Posts
    1,528
    so the program runs when you click the icon or not?

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    7
    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
    Location
    Europe
    Posts
    448
    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
    Posts
    4,662
    Getting filename of my program

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

    gg

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, 02: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, 12:01 AM
  5. Application path
    By zigona in forum C++ Programming
    Replies: 4
    Last Post: 11-18-2001, 03:37 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21