programming using linux

This is a discussion on programming using linux within the C Programming forums, part of the General Programming Boards category; I just compiled my first program using the CLI in linux. i compiled it using gcc gcc test.c it gave ...

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    70

    programming using linux

    I just compiled my first program using the CLI in linux.
    i compiled it using gcc
    gcc test.c
    it gave me a.out

    now i thought since it was an executable, so all i needed to write was
    a at the command prompt and it would execute

    however it says something like
    bash does not recognise the command

    i also tried a.out with the same results.

    what shoudl i do?

  2. #2
    Wannabe Coding God
    Join Date
    Mar 2003
    Posts
    259
    ./a.out to change what the executable is called use -o when using gcc.
    Last edited by Shogun; 06-11-2004 at 03:16 PM.
    They say that if you play a Windows Install CD backwords, you hear satanic messages. That's nothing; play it forward and it installs Windows.

  3. #3
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    really you should do
    Code:
    gcc -o test test.c -Wall -pedantic
    then to run
    Code:
    ./test
    Of course it gets more advanced in certain senarios.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,451
    Calling a program test is a really bad idea
    There's an existing command of the same name, which causes some fun from time to time
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,648
    >> Calling a program test is a really bad idea
    I can remember learning that one the "hard way"

    gg

  6. #6
    Registered User
    Join Date
    May 2004
    Posts
    70
    what does this program "test" do,
    can you guys/gals point me to resources which illustrates basic command line compiliing, execution and debugging

  7. #7
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    that really is about it. If you want to define something in your compilation then you use -D. If you want to Include another directory in compilation -I. If you want optimization(only goes up to 3 by default) the do -O3 But if you feel really smart read.
    Code:
    man gcc
    Then you will feel fine.
    Last edited by linuxdude; 06-11-2004 at 06:44 PM.

  8. #8
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    To answer your initial question, just type in './a.out'. The './' at the start tells bash to look for the program 'a.out' in the current folder. Otherwise it will only look in your bin folders.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  9. #9
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >what does this program "test" do
    Comparisons and file type checking. You'll see it a bunch in shell scripts.
    My best code is written with the delete key.

  10. #10
    Registered User
    Join Date
    May 2004
    Posts
    70
    thanks for helping me out guys/gals

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Thinking of upgrading to linux...
    By Yarin in forum General Discussions
    Replies: 37
    Last Post: 07-24-2009, 11:40 AM
  2. Wireless Network Linux & C Testbed
    By james457 in forum Networking/Device Communication
    Replies: 3
    Last Post: 06-11-2009, 11:03 AM
  3. Dabbling with Linux.
    By Hunter2 in forum Tech Board
    Replies: 21
    Last Post: 04-21-2005, 04:17 PM
  4. installing linux for the first time
    By Micko in forum Tech Board
    Replies: 9
    Last Post: 12-06-2004, 04:15 AM

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