Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    [beginner] Trying to compile C program


    Im learning C, and have been using Gedit in a VM with an online course.

    I've just installed Ubuntu over my Win7 laptop and am trying to compile / run a basic program. (hello world basic ! )

    I've got Gedit, have written the program, saved it to documents (test.c) and gone to the directory in the terminal - but when I type the following :

    gcc -o test test.c

    As per this instruction I get the error :

    gcc: error: test: No such file or directory

    I'm sure I'm doing something wrong on a pretty simple level....

    Any ideas?

    cheers

  2. #2
    Linux Guru
    Join Date
    Dec 2013
    Location
    Victoria, B.C. Canada
    Posts
    2,103
    If you are copying things exactly as typed and returned that error message makes no sense. If you put the -o before test.c you woould get that error i.e. gcc -o test.c test.

    You could type:
    Code:
    gcc test.c
    and see what happens. Without any arguments gcc will produce, presuming a correct input file, an executable called a.out which you can then run.

  3. #3
    argh no, typing error - it was referring to the header file not the actual file

    <stdio.c>

    it's working now

  4. $spacer_open
    $spacer_close

Posting Permissions

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