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

moore1879

macrumors newbie
Original poster
May 22, 2008
15
0
I can't seem to compile .c source code. I need to be able to in order for make, and make install to work properly. Any suggestions? Here is a sample of what is going on:

These are the contents of hello.c.

#include <stdio.h>

main()
{
printf("Hello World");
}


gcc hello.c prints:

hello.c:1:19: error: stdio.h: No such file or directory
hello.c: In function 'main':
hello.c:5: warning: incompatible implicit declaration of built-in function 'printf'


gcc --version prints:

i686-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5250)
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 

eddietr

macrumors 6502a
Oct 29, 2006
807
0
Virginia
Did you check to see if stdio.h is in /usr/include/ or some other place where gcc can find it?

If you do 'gcc -v hello.c' you can see where gcc is looking for stdio.h
 

moore1879

macrumors newbie
Original poster
May 22, 2008
15
0
I just checked /usr/include and stdio.h is not there. I know absolutely nothing about the C programming language. I just want to be able to install source code. What do I do?
 

moore1879

macrumors newbie
Original poster
May 22, 2008
15
0
Yes, that is how I installed gcc, with the developers' tools from the apple installation disk.
 

Sander

macrumors 6502a
Apr 24, 2008
521
67
Something must have gone wrong with the installation. GCC normally should be able to find its standard headers without further effort on your part. You could try reinstalling.

Incidentally, your test program is not valid C. It should be:

#include <stdio.h>

int main(void)
{
printf("Hello World\n");
return 0;
}

Cheers,
Sander
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
I would try to reinstall the developer tools.

What hits do you get if you try:
locate stdio.h
?

If there are any, you could try to add the option:
-I /path/to/directory/here

to your gcc command string.

-Lee
 

eddietr

macrumors 6502a
Oct 29, 2006
807
0
Virginia
Yes, that is how I installed gcc, with the developers' tools from the apple installation disk.

That's strange. You should have gotten the headers as well then.

So one thing you might try is reinstalling XCode. It seems you are on Tiger, is that right?

So the latest version of XCode for Tiger is 2.5. If you're going to reinstall, you might as well use that. You can get it from http://developer.apple.com, go to ADC Member page, register if necessary (if you don't already have an account there), and then do to Downloads->Developer Tools and look for XCode 2.5.
 

moore1879

macrumors newbie
Original poster
May 22, 2008
15
0
I am going to reinstall the developer tools. I'll let y'all know how it goes.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.