Find the answer to your Linux question:
Results 1 to 3 of 3
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Mar 2014
    Posts
    121

    [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 Engineer
    Join Date
    Dec 2013
    Posts
    1,305
    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
    Linux Newbie
    Join Date
    Mar 2014
    Posts
    121
    argh no, typing error - it was referring to the header file not the actual file

    <stdio.c>

    it's working now

Posting Permissions

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