LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Trouble compiling simple hello world program (https://www.linuxquestions.org/questions/linux-newbie-8/trouble-compiling-simple-hello-world-program-763029/)

knightstreet 10-19-2009 03:58 PM

Trouble compiling simple hello world program
 
Hi,

I'm a newbie to linux and have installed debian on my machine.

I installed gcc and am trying to compile a really really basic 'hello world' app but am having problems. I'm not sure this is the right thread/forum to post this on so go easy if I'm in the wrong park!

The code is thus:


Code:

#include <stdio.h>

int main(void)
{
printf("Hello world");
}


Complex eh?

I use the following to compile:

gcc -o program main.c

I get the followign error messages related to stdio.h:

/usr/include/libio.h:332: error: expected specifier-qualifier-list before size_t

I have a lot more similar messages. Can anyone help me out?

Thanks,

Chris.

neonsignal 10-19-2009 04:27 PM

What are the first few errors you are getting? It looks like it is not finding some of the header files included by stdio.h.

How did you install gcc?

knightstreet 10-19-2009 05:25 PM

Hi neonsignal,

I installed it using : apt-get install gcc

The install seems to have worked, I do gcc --version and it goves me Debian 4.3.2-1.1

The remainder of the errors are similar pointing to libio.h and 'expected declaration specifiers' mainly.

I'll try to get the log but I'm running a VM and am having difficulty with the shared folders.

neonsignal 10-19-2009 06:06 PM

The errors are because size_t and probably other standard types have not been defined.

I expect that one of the first error messages would be a failed include. This might be a path problem, or a package that didn't install properly - in a standard installation, you normally wouldn't have to do anything to get this working.

neonsignal 10-19-2009 06:20 PM

Perhaps try installing the following packages:
Code:

apt-get install build-essential libc6-dev

smeezekitty 10-19-2009 06:42 PM

post all the errors.

knightstreet 10-19-2009 07:03 PM

Thanks neonsignal, that fixed my problem.

I figured a normal install would put all the path declarations in for me and I wouldn't have to do much.

Thanks again for the help, I really appreciate it.


All times are GMT -5. The time now is 02:01 AM.