LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-21-2006, 03:01 PM   #1
myrto
LQ Newbie
 
Registered: Dec 2006
Posts: 29

Rep: Reputation: 15
Unhappy compiling and running a c program in Linux


I just installed Linux 10.1 and I am really new at this. I wanted to know how to compile and run a program in c language. I tried using the bash shell but I couldn't find the right command.

Thanks.
 
Old 12-21-2006, 03:15 PM   #2
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 74
Hello and welcome to LQ. There is no such thing as Linux 10.1, so you need to mention the complete name of the distribution you are using. What is this C program you wish to compile. Is it one you created yourself or downloaded from somewhere to install on your system?
 
Old 12-21-2006, 03:27 PM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
Read through "info gcc". ( Or enter "info:gcc" in the konqueror web browser )
Also make sure you have "make" installed.

The "glibc-html" package would do you well in referencing the glibc linux library.

Your local book store may have books on programming in C and C++ in Linux, which could help get you started as well.

You're message says you installed Linux 10.1, but that doesn't indicate which distro your version number is referencing. You may want to add your distro to your profile so we can tell and maybe provide better information on latter posts.

----

The moderator posted his message as I was writing mine. I had taken your question to mean that you wanted to learn to write C program and compile them in Linux.

Last edited by jschiwal; 12-21-2006 at 03:29 PM.
 
Old 12-21-2006, 03:36 PM   #4
raskin
Senior Member
 
Registered: Sep 2005
Location: Russia
Distribution: NixOS (http://nixos.org)
Posts: 1,899

Rep: Reputation: 68
I suppose that you use SuSE distribution of GNU/Linux, especially the one named "SuSE Linux 10.1"? And that you have written a program and want to compile it. And that you did not try running
Code:
man gcc
.

Then you should cd to directory with program and run
Code:
gcc -o program program.c
, which will produce executable file program, that can be run with command
Code:
./program
.

Try reading info gcc also.

Nevertheless, it is pointless to name version of your distribution without naming vendor, and it is always better to ask exact questions.

Last edited by raskin; 12-21-2006 at 03:37 PM.
 
Old 12-21-2006, 03:55 PM   #5
mushk45
LQ Newbie
 
Registered: Sep 2005
Distribution: Slackware 10.0 , Fedora 3, SUSE 9.2, Knoppix 5.0.1 (Live CD)
Posts: 25

Rep: Reputation: 15
Quote:
Linux 10.1
LOL!

you might need to install "gcc" also...
 
Old 12-21-2006, 03:59 PM   #6
raskin
Senior Member
 
Registered: Sep 2005
Location: Russia
Distribution: NixOS (http://nixos.org)
Posts: 1,899

Rep: Reputation: 68
Well, if it were "Linux 6.10" I would definitely say "apt-get build-essentials", but it is not...
 
Old 12-21-2006, 06:11 PM   #7
myrto
LQ Newbie
 
Registered: Dec 2006
Posts: 29

Original Poster
Rep: Reputation: 15
I actually found out that due to a mistake during installation I didn't have gcc installed and that was the source of the problem. When I tried to compile the program with gcc it returned "command not found" because of course it couldn't find it. Thanks.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
compiling &running C program naobi Programming 2 09-11-2006 01:42 PM
Compiling a program for X-Linux 4.1 steaktc Programming 7 11-01-2005 08:36 AM
Having trouble compiling/running java on linux nejiron Linux - Software 12 11-11-2003 01:38 AM
compiling a program in Linux embalmedlenin Programming 4 08-29-2003 06:16 PM
Running a program after compiling - How? halem Linux - Newbie 2 02-24-2001 11:11 AM


All times are GMT -5. The time now is 09:10 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration