Thread: a.out

  1. #1
    Registered User
    Join Date
    Aug 2008
    Posts
    55

    a.out

    How do I run a .out file in linux? I compiled with gcc.

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    ./a.out

  3. #3
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Alternatively, if you don't want it to compile to a.out you can use the -o option. Like gcc mytest.c -o test will create an executable named test (which you run of course with ./test)

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by C_ntua View Post
    Alternatively, if you don't want it to compile to a.out you can use the -o option. Like gcc mytest.c -o test will create an executable named test (which you run of course with ./test)
    Although "test" is a very bad name for a program in unix, as there is a standard command that is called test - often a builtin of the command shell.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Jan 2007
    Posts
    330
    haha I remember wasting loads of time when I tried running a program named test on linux for the first time. But it's one of those things you have to go through to learn that you always use ./ when running executables in the current directory

  6. #6
    Registered User
    Join Date
    Aug 2008
    Posts
    55
    Thanks. Why is it ./a.out instead of just a.out?

  7. #7
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Quote Originally Posted by Nextstopearth View Post
    Thanks. Why is it ./a.out instead of just a.out?
    It's already been hinted at in the post just above yours.

    Quote Originally Posted by KIBO
    But it's one of those things you have to go through to learn that you always use ./ when running executables in the current directory
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  8. #8
    Ex scientia vera
    Join Date
    Sep 2007
    Posts
    477
    Just writing "program" will try to find the program in all of the directories specified in your path environment variable, which does not contain your current working directory in most cases. This is why you need to use "./" - . means the current directory.
    "What's up, Doc?"
    "'Up' is a relative concept. It has no intrinsic value."

  9. #9
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Quote Originally Posted by IceDane View Post
    Just writing "program" will try to find the program in all of the directories specified in your path environment variable, which does not contain your current working directory in most cases. This is why you need to use "./" - . means the current directory.
    LOL! I thought ./ meant something like "run". Like run a.out. All this time, I was misguided. I see the light now...

  10. #10
    Registered User
    Join Date
    Aug 2008
    Posts
    55
    Quote Originally Posted by IceDane View Post
    Just writing "program" will try to find the program in all of the directories specified in your path environment variable, which does not contain your current working directory in most cases. This is why you need to use "./" - . means the current directory.
    I see, that makes sense. Thanks.

  11. #11
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    It's like that so you can run regular commands without programs in the present working directory masking them.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. *** glibc detected *** a.out: realloc()
    By msshapira in forum C Programming
    Replies: 9
    Last Post: 01-27-2009, 09:49 AM
  2. a.out remains unchanged
    By muthus in forum C Programming
    Replies: 14
    Last Post: 01-19-2008, 05:26 PM
  3. General a.out redirection question under Linux
    By merixa in forum C++ Programming
    Replies: 3
    Last Post: 11-07-2005, 05:36 PM
  4. Change Name of a.out
    By cdonlan in forum Linux Programming
    Replies: 2
    Last Post: 02-01-2005, 04:51 AM
  5. overgrown .exe files
    By R.Stiltskin in forum C++ Programming
    Replies: 13
    Last Post: 04-09-2004, 11:19 AM