C programming on Ubuntu
Which package do I need to install to get the standard library files for c programming?
Currently, not even #include <stdio.h> works. I thought the standard lib files automatically were added when installing the OS, but I guess I was wrong. :) |
Yoou need to install the gcc compiler and the concerned libraries for C programs. You can search for them in the synaptic manager.
|
Quote:
|
When you installed gcc, the standard libraries should have been included as well. What commands are you running when you try to compile the program you have written?
|
My test program is as follows:
#include <stdio.h> int main() { printf("Hello!"); } and I compile it with gcc <filename> I installed gcc using synaptic, but it seems as the libraries weren't installed by default. |
Try the following
Code:
$gcc -o hello hello.c Code:
$./hello |
(I used "gcc <filename>" just as a test. I know that the binary file is then named "a.out")
Okay, I think I fixed it, but I don't know how. :) I tried "gcc-4.0" instead of just "gcc", and then it compiled. I seems the libraries were installed after all. But what I don't understand is WHY this worked. "gcc" and "gcc-4.0" is exactly the same, as far as I can tell: running "gcc --version" and "gcc-4.0 --version" displays the exact same information. Anyways, now even "gcc <filename>" works. :) I'll try and build a larger project, and see what happens. Thanks for the help anyways! |
hi,
i am also trying to compile a simple helloworld program. i have all the gcc things in the synaptic pakage manager installed. i open a termainal window and went to the directory where the helloworld.c program is. when i use gcc helloworld.c i get the following: error: stdio.h: No such file or directory. i get the same error when i use $gcc -o helloworld helloworld.c i am very new to linux and c. Can anybody help me? scobie |
Try and execute "gcc-4.0 <source file>", maybe it works.
|
Quote:
|
Quote:
|
ty reddazz i wasnt sure if the order things are in mattered i know some or most commands in termianl doesnt really matter.
|
sudo apt-get install build-essential
That should get you started. |
Quote:
|
All times are GMT -5. The time now is 08:08 AM. |