Sandra Bae Sandra Bae - 2 months ago 12
C Question

How to compile C file through Terminal

I'm trying to compile a C file that I have saved on my computer and I'm trying to compile the file with Terminal on my Mac OS X El Capitan by typing out

gcc - g -wall -werror -o getit.out -std=c11 getit.c
, but I keep getting this error stating:

Sandra$ gcc -g -wall -werror -o getit.out -std=c11 getit.c
clang: error: unknown argument: '-wall'
clang: error: unknown argument: '-werror'
clang: error: -E or -x required when input is from standard input
clang: error: no such file or directory: 'g'


I have downloaded Xcode and installed it, but I'm not sure why I'm getting this error. If anyone could provide insight that would be greatly appreciated. Thank you!

EDIT:

So as stated by @md xf I tried
gcc - g -Wall -Werror -o getit.out -std=c11 getit.c

but I still got an error stating

clang: error: -E or -x required when input is from standard input
clang: error: no such file or directory: 'g'


**Forgot to list all of my errors in my original post

Answer

As far as I know, the W in -Wall and -Werror need to be capitalized. A capital flag and a lowercase flag will have two completely different functions. So you would rewrite it as gcc -Wall -Werror -std=c11 -o getit.out getit.c.

In response to your edit you could also try:

  1. writing getit.c as your first option
  2. making sure there is no space between - and g (-g)
  3. removing the -std=c11 if it's not absolutely necessary

It seems like you are typing something different than what's shown here. The error messages make it seem like there's a space between - and g.

Comments