GCC error in compiling

This is a discussion on GCC error in compiling within the C Programming forums, part of the General Programming Boards category; I recently had to reformat my computer and when I reinstalled Cygwin and tried compiling through gcc I get an ...

  1. #1
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463

    GCC error in compiling

    I recently had to reformat my computer and when I reinstalled Cygwin and tried compiling through gcc I get an error that there is no input files and no such file or directory.

    I created a folder called home and then the user name in that and put the source files there, but I still get the same error.

    Any help?

    Cheers

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Is the error that the compiler can't be found? That is, if you just type "gcc" on the command line, does it work or not? [It will say somethign like "nothing to compile" if it works. ]

    --
    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.

  3. #3
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    if i type just gcc, it says gcc: no input files

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    So what do you type when it fails, and what is the EXACT error message (use copy from the command window and paste it into your post here).

    --
    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
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    I'd assume you're not giving gcc any files to work with (ie no arguments), paste exactly what the terminal says (and what you type) here -- as matsp said.

  6. #6
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    If i type just "gcc" it says:

    $gcc
    gcc: no input files

    If i type gcc -Wall -o hw3 hw3.c it says:

    $gcc -Wall -o hw3 hw3.c
    gcc: hw3.c: No such file or directory
    gcc: no input files

  7. #7
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    And there definitely is a hw3.c file in your current directory?

    --
    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.

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,823
    Show your 'ls' result as well.
    Or otherwise show that there really is a file with that name.

    If you type
    ls hw3.c
    does that also produce an error message?
    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.

  9. #9
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    That's kind of the problem, I don't know what or where my current directory is, before I had reformatted my computer, when I had installed cygwin, there was a folder automatically created called "home" and inside that folder there was another folder called "Owner"

    And now when I reinstalled it, no such folder was created. So i manually created it, and put the files in there, infact I pasted the hw3.c file in quite a few places.

  10. #10
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    If i type ls hw3.c

    it says:

    ls: cannot access hw3.c: No such file or directory

  11. #11
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    The files that you specify to gcc 'hw3.c' is relative to the current working directory.

    For example, if you had, /home/jfonseka/mysource which contained 'hw3.c'

    You'd do something like,
    Code:
    > cd /home/jfonseka/mysource
    > gcc -Wall -o hw3 hw3.c
    Since now the folder which contains hw3.c is the current working directory.

    Code:
    $gcc
    Won'd do anything because you haven't told it to, it expects input files (you've speicifed none) -- I suggest doing a man gcc.

    [edit] Ahh poo, really late[/edit]

    If you have no idea where hw3.c is, search for it
    Code:
    > find / -name hw3.c

  12. #12
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    Quote Originally Posted by zacs7 View Post
    The files that you specify to gcc 'hw3.c' is relative to the current working directory.

    For example, if you had, /home/jfonseka/mysource which contained 'hw3.c'

    You'd do something like,
    Code:
    > cd /home/jfonseka/mysource
    > gcc -Wall -o hw3 hw3.c
    Since now the folder which contains hw3.c is the current working directory.

    Code:
    $gcc
    Won'd do anything because you haven't told it to, it expects input files (you've speicifed none) -- I suggest doing a man gcc.

    [edit] Ahh poo, really late[/edit]
    Ah ha, now it worked, i didn't know i had to change directory like that, thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. gcc compiling and linking problem
    By maven in forum C Programming
    Replies: 6
    Last Post: 11-14-2008, 05:28 AM
  2. GCC: Compiling with both static and shared libraries
    By eatwithaspork in forum C Programming
    Replies: 4
    Last Post: 06-23-2008, 02:48 PM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 03:39 PM
  4. problems compiling in gcc
    By ra_mer in forum C Programming
    Replies: 6
    Last Post: 09-04-2006, 10:13 PM
  5. Compiling in Linux - GCC
    By gqchynaboy in forum C Programming
    Replies: 15
    Last Post: 03-02-2005, 12:15 PM

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