LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-29-2006, 07:07 AM   #1
sunnydayzrback
LQ Newbie
 
Registered: Jan 2006
Posts: 25

Rep: Reputation: 15
how tomake gcc command work


How do we configure gcc command in Ubuntu 5.10
I installed Gcc from syanptic manager but it must be built or something before it works . i have no previous experience on linx so plz help me how to install gcc
 
Old 01-29-2006, 08:36 AM   #2
Artanicus
Member
 
Registered: Jan 2005
Location: Finland
Distribution: Ubuntu, Debian, Gentoo, Slackware
Posts: 827

Rep: Reputation: 31
IF you installed it, then there is no further configuration needed. It should be ready to use, unless theres something Synaptic told you to do? IF it did, then could you please repeat that for us.
 
Old 01-29-2006, 10:23 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Have you tried to build something using gcc? eg using the configure, make, and make install steps?
As the man said, when you install something with Synaptic, that is usually it. Do you have docs for gcc that tell yo to do something else?
 
Old 01-30-2006, 08:25 AM   #4
sunnydayzrback
LQ Newbie
 
Registered: Jan 2006
Posts: 25

Original Poster
Rep: Reputation: 15
#include<stdio.h>
main()
{
printf(" hi, hw r u?");
}
for compiling this program it gave the following error

sunil@pogo:~$ gcc asd.c
asd.c:1:18: error: stdio.h: No such file or directory
asd.c: In function ‘main’:
asd.c:7: warning: incompatible implicit declaration of built-in function ‘printf


i think we should buildit first. plz tell me how to do it??
 
Old 01-30-2006, 05:01 PM   #5
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
sudo apt-get install build-essential should install the basic necessary software you need to compile a C program.


Håkan
 
Old 01-31-2006, 01:35 AM   #6
sunnydayzrback
LQ Newbie
 
Registered: Jan 2006
Posts: 25

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by hw-tph
sudo apt-get install build-essential should install the basic necessary software you need to compile a C program.


Håkan

after doing that

sunil@pogo:~$ sudo apt-get install build-essential
Password:
Reading package lists... Done
Building dependency tree... Done
The following extra packages will be installed:
dpkg-dev g++ g++-4.0 libc6-dev libstdc++6-4.0-dev linux-kernel-headers make
Suggested packages:
debian-keyring gcc-4.0-doc lib64stdc++6 glibc-doc manpages-dev
libstdc++6-4.0-doc stl-manual
The following NEW packages will be installed:
build-essential dpkg-dev g++ g++-4.0 libc6-dev libstdc++6-4.0-dev
linux-kernel-headers make
0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
Need to get 0B/8268kB of archives.
After unpacking 34.1MB of additional disk space will be used.
Do you want to continue [Y/n]? y

Preconfiguring packages ...
Selecting previously deselected package linux-kernel-headers.
(Reading database ... 61390 files and directories currently installed.)
Unpacking linux-kernel-headers (from .../linux-kernel-headers_2.6.11.2-0ubuntu13_i386.deb) ...
Selecting previously deselected package libc6-dev.
Unpacking libc6-dev (from .../libc6-dev_2.3.5-1ubuntu12_i386.deb) ...
Selecting previously deselected package libstdc++6-4.0-dev.
Unpacking libstdc++6-4.0-dev (from .../libstdc++6-4.0-dev_4.0.1-4ubuntu9_i386.deb) ...
Selecting previously deselected package g++-4.0.
Unpacking g++-4.0 (from .../g++-4.0_4.0.1-4ubuntu9_i386.deb) ...
Selecting previously deselected package g++.
Unpacking g++ (from .../g++_4%3a4.0.1-3_i386.deb) ...
Selecting previously deselected package make.
Unpacking make (from .../archives/make_3.80-9_i386.deb) ...
Selecting previously deselected package dpkg-dev.
Unpacking dpkg-dev (from .../dpkg-dev_1.13.10ubuntu4_all.deb) ...
Selecting previously deselected package build-essential.
Unpacking build-essential (from .../build-essential_11.1_i386.deb) ...
Setting up linux-kernel-headers (2.6.11.2-0ubuntu13) ...
Setting up libc6-dev (2.3.5-1ubuntu12) ...
Setting up make (3.80-9) ...

Setting up dpkg-dev (1.13.10ubuntu4) ...
Setting up libstdc++6-4.0-dev (4.0.1-4ubuntu9) ...
Setting up g++-4.0 (4.0.1-4ubuntu9) ...
Setting up g++ (4.0.1-3) ...

Setting up build-essential (11.1) ...
sunil@pogo:~$ ls
asd.c asd.c~ Desktop
sunil@pogo:~$ gcc asd.c
asd.c:1:19: error: stdio.c: No such file or directory
asd.c: In function ‘main’:
asd.c:4: warning: incompatible implicit declaration of built-in function ‘printf’
sunil@pogo:~$ g++ asd.c
asd.c:1:19: error: stdio.c: No such file or directory
asd.c: In function ‘int main()’:
asd.c:4: error: ‘printf’ was not declared in this scope
sunil@pogo:~$

even now the program is not being compiled

Last edited by sunnydayzrback; 01-31-2006 at 01:41 AM.
 
Old 01-31-2006, 01:48 AM   #7
Artanicus
Member
 
Registered: Jan 2005
Location: Finland
Distribution: Ubuntu, Debian, Gentoo, Slackware
Posts: 827

Rep: Reputation: 31
Quote:
error: stdio.c
stdio.c or stdio.h ?
 
Old 01-31-2006, 08:38 AM   #8
sunnydayzrback
LQ Newbie
 
Registered: Jan 2006
Posts: 25

Original Poster
Rep: Reputation: 15
Question

it worked thank u the program is being compiled but its not running correctly
i used the directions gave in following link

http://users.actcom.co.il/~choo/lupg...c-on-unix.html

but when running it gave the following error


sunil@pogo:~$ gcc asd.c
sunil@pogo:~$ ./asd.c
./asd.c: line 5: syntax error near unexpected token `"hello world"'
./asd.c: line 5: `printf("hello world");'
sunil@pogo:~$


this is the program


#include <stdio.h>
main()
{

printf("hello world");

}
when i used "gdb ./a.out"(without quotes) and ran it by using run asd.c ,it worked why is this so cant i run the program in the normal terminal mode?

Last edited by sunnydayzrback; 01-31-2006 at 09:47 AM.
 
Old 01-31-2006, 11:17 AM   #9
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Quote:
Originally Posted by sunnydayzrback
sunil@pogo:~$ gcc asd.c
sunil@pogo:~$ ./asd.c
./asd.c: line 5: syntax error near unexpected token `"hello world"'
./asd.c: line 5: `printf("hello world");'
You shouldn't be trying to "run" your source code file. The "gcc asd.c" line will create an executable named a.out, which you run. If you want the executable to be named something else, use gcc's -o switch:

$ gcc asd.c -oasd

This will create an executable named asd that you can run.
 
Old 02-01-2006, 12:57 AM   #10
sunnydayzrback
LQ Newbie
 
Registered: Jan 2006
Posts: 25

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Nylex
You shouldn't be trying to "run" your source code file. The "gcc asd.c" line will create an executable named a.out, which you run. If you want the executable to be named something else, use gcc's -o switch:

$ gcc asd.c -oasd

This will create an executable named asd that you can run.
Thank you I got it.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
makefile gcc command cannot be found Mogul83 Programming 7 05-31-2005 03:11 AM
bash: gcc: command not found sandbag Linux - Software 8 05-05-2005 12:17 PM
Tomake a cd which can install a LSF on any system jenish Linux From Scratch 3 04-16-2005 12:07 AM
gcc command dement Linux - Newbie 3 03-26-2005 04:58 AM
problem using gcc -lXi command... manikantha Programming 0 01-24-2005 05:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration