Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sg001

macrumors newbie
Original poster
Jul 30, 2012
9
0
Hi could someone please have a look at the following steps to see if there is something I'm missing.

1/ I have d/lded xcode (current) and installed command line tools.

2/ for some reason edit is not opening in my terminal window.

ie I type "gedit hello.c"

output:- bash:gedit: command not found

but I just use pico and it seams to work i.e.

"pico hello.c"

and it opens a pico editing window.

secondly the compiler does not seem to work in terminal.

ie/

i create a new file "mkdir hello.c"

"cd hello.c"

now i am in hello.c

next step

"pico hello.c"

and i type this simple code

#include <stdio.h>

int main(int argc, char * argv[]){

printf("Hello World!\n");
printf("Goodbye World!\n");
return 0;
}


now I save by

^o

and save file "hello.c"

now back to terminal still in file hello.c

"gcc -Wall -Werror -O -o hello hello.c"

output:

i686-apple-darwin11-llvm-gcc-4.2: hello.c: No such file or directory
i686-apple-darwin11-llvm-gcc-4.2: no input files"

???

This is really annoying me I feel I have tried everything

please please help. Thanks
 
right before you try
Code:
gcc -Wall -Werror -O -o hello hello.c
please type
Code:
pwd
ls *.c
and post the results here it doesn't look like you are in the right working directory when you issue the gcc command.

B
 
for some reason edit is not opening in my terminal window.
ie I type "gedit hello.c"

output:- bash:gedit: command not found

Gedit is the official text editor of the GNOME desktop environment. It doesn't come standard on OS X. You can get/compile it yourself with MacPorts, Homebrew or other alternatives.
Gedit Mac OS X packages : http://ftp.gnome.org/pub/GNOME/binaries/mac/gedit/3.2/
 
Last edited:
right before you try
Code:
gcc -Wall -Werror -O -o hello hello.c
please type
Code:
pwd
ls *.c
and post the results here it doesn't look like you are in the right working directory when you issue the gcc command.

B

hello.c helloworld.c

123.c:
iapple

hellohello.c:
123.c hellohello.c

iapple.c:


pls note I have tried doing this with a few different file names as I have tried to get it working a few times.

Thanks.
 
Open Terminal and cd into your directory where your .c file is and type :

Code:
gcc -Wall -Werror -O -o hello

then press tab to see if you see your hello.c file. If you do see it press h and tab again. Bash will autocomplete.

balamw asked for the result of the pwd command. The result will be a POSIX style path using the slash / as the separator for directories eg /path/to/some/folder.

Example :

/Users/test/Desktop/hello.c
 

Attachments

  • Picture 3.png
    Picture 3.png
    67.3 KB · Views: 160
  • Picture 5.png
    Picture 5.png
    72.9 KB · Views: 151
Last edited:
pls note I have tried doing this with a few different file names as I have tried to get it working a few times.

You're not helping yourself by giving your folders the same name as source files. In general that can be a bad idea. If you want to reinforce that the folder has a C file in it, you could call it "hello_c" but don't call it "hello.c" that is a surefire path to confusion.

B
 
You're not helping yourself by giving your folders the same name as source files. In general that can be a bad idea. If you want to reinforce that the folder has a C file in it, you could call it "hello_c" but don't call it "hello.c" that is a surefire path to confusion.

B

Ok I figured it out now thanks for the help.

I think thats what I was confused about.. I thought the folders had to be the same name as the c file.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.