gcc compiler, no stdio.h found

L

lzco

Guest
hi,
I want to compile C programs using the terminal (Darwin). I have an ibook with os x 10.4.2 .
I installed the Xcode Tools development package, along with gcc4.0 and gcc3.3 packages that come with Tiger under the Applications/Installers folder.

When I try to compile a simple hello world program, this is what i get:


ibook:~/Documents era$ ls
assign1 hello.c
ibook:~/Documents era$ cat hello.c
#include <stdio.>

main() {
printf("Hello World!\n");
}

ibook:~/Documents era$ gcc -c hello.c
hello.c:1:18: error: stdio.: No such file or directory
hello.c: In function 'main':
hello.c:4: warning: incompatible implicit declaration of built-in function 'printf'
ibook:~/Documents era$ cd /usr/include
ibook:/usr/include era$ ls
gcc stdint.h
ibook:/usr/include era$ ls
gcc stdint.h
ibook:/usr/include era$ cd gcc
ibook:/usr/include/gcc era$ ls
darwin
ibook:/usr/include/gcc era$ cd darwin
ibook:/usr/include/gcc/darwin ra$ ls
3.3 3.3-fast 4.0 default
ibook:/usr/include/gcc/darwin era$ cd 4.0
ibook:/usr/include/gcc/darwin/4.0 era$ ls
c++ ppc_intrinsics.h
machine stdint.h

I would like to know how to properly installed gcc so that I can compile from the terminal, since I like writing my c programs using a simple text editor.

I thought that by just installing the XCode Tools I was going to be able to compile c programs, but I guess i was wrong :dummy:

In advance, thanks for your help
 
OP
L

lil

Guest
You forgot the h on stdio (you have <stdio.>) :flower: e.g:

/* sample program */

#include <stdio.h>

void main()
{
printf("Hello Mac Forums!\n");
}

/* end code */

Hope this helps!
Vicky :flower:
 
OP
L

lzco

Guest
Hi Vicky,

I still haven't sold my problem... I tried your sample program and it gives me the same error.

ibook:~/Documents era$ gcc hello.c
hello.c:3:19: error: stdio.h: No such file or directory
hello.c: In function 'main':
hello.c:7: warning: incompatible implicit declaration of built-in function 'printf'
hello.c:6: warning: return type of 'main' is not 'int'
ibook:~/Documents era$ cat hello.c
/* sample program */

#include <stdio.h>

void main()
{
printf("Hello Mac Forums!\n");
}

/* end code */
ibook:~/Documents era$

Any suggestions as to how to install gcc, it seems like the XCode installer doesn't let me compile from Darwin

Thanks,

lzco


lil said:
You forgot the h on stdio (you have <stdio.>) :flower: e.g:

/* sample program */

#include <stdio.h>

void main()
{
printf("Hello Mac Forums!\n");
}

/* end code */

Hope this helps!
Vicky :flower:
 
Joined
Feb 9, 2005
Messages
2,340
Reaction score
82
Points
48
Location
DFW
Your Mac's Specs
MacBook Pro 13" | MacBook Pro 13" | Mac Mini 2GHz C2D
i would try to reinstall XCODE. maybe something did not get installed correctly.
 
OP
L

lil

Guest
Try using spotlight (command + space) to search for stdio.h or just .h for any include files.

Vicky
 
OP
L

lzco

Guest
I uninstalled XCodeTools, and installed it back again.
Now it works, I don't know what went wrong the first time, but I can compile c programs now.

thanks! :dive: :dive:
 
OP
L

lil

Guest
Great, glad it's sorted. I must install XCode myself sometime, but I have enough projects as it is to concentrate on, let alone programming!

Vicky :flower:
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top