Find the answer to your Linux question:
Results 1 to 5 of 5
Just for fun I decided to port a very minimal Windows/MS shell application of mine to Linux (shell only installation). I ran aptitude and after a while I had g++-3.4 ...
  1. #1
    Just Joined!
    Join Date
    Jan 2007
    Posts
    13

    WTF!!! Compile/Link & Run, how hard can it be?

    Just for fun I decided to port a very minimal Windows/MS shell application of mine to Linux (shell only installation).

    I ran aptitude and after a while I had g++-3.4 installed.
    I copied my single cpp file to my home dir and ran:
    # g++-3.4 Myfile.cpp
    and after a cleaning up a few issues I suddenly got an a.out.

    Happy as ever I now typed
    # a.out
    but then get a "command not found". Huh, what's this?
    Typing
    # a TAB, nothing happens
    # a. TAB, nothing happens.

    Seems like system doesn't accept my file as an executable even though file flags are set to x. Where did I go wrong? Shouldn't an executable be runnable this way?

  2. #2
    Linux User towy71's Avatar
    Join Date
    May 2006
    Location
    West Wales
    Posts
    322
    Code:
    chmod x a.out
    free/libre/open software for the people by the people
    Linux user #185360

  3. #3
    Just Joined!
    Join Date
    Jan 2007
    Posts
    13
    x flag is already set for ogu by compiler/linker.

  4. #4
    Linux Newbie rudie_rage's Avatar
    Join Date
    Jun 2007
    Location
    Canada
    Posts
    133
    try ./a.out
    when you enter just a.out, it searches through /bin and /sbin and the like looking for the file. typing the ./ is like saying 'hey, look for the program in the directory im in'

    PS: if you dont want the output of the compiler to save to a.out, you can try specifying the desired filename with the -o (lowercase letter o)

    ex gcc -o myprogram myprogram.cpp
    Living the digital dream....
    Disclaimer: I may be wrong since I was once before.
    Breathe out so I can breathe you in ~~Everlong

  5. #5
    Just Joined!
    Join Date
    Jan 2007
    Posts
    13
    Ah, thanks!

    Should have thought of that, still to used to how windows apply search paths I guess...

    The code snippet works like a charm so now I just have to polish it a bit and figure out how to execute it periodically (it's for retreiving data once a day from a web server). Maybe it would have been easier to do this with a script language but I'm to used to C...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •