LinuxQuestions.org
Visit Jeremy's Blog.
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 05-03-2011, 06:56 PM   #1
archie101
Member
 
Registered: Apr 2011
Location: u.s
Distribution: arch linux
Posts: 48

Rep: Reputation: 0
c compiler


i was wandering if there was any good c compilers that are free for linux?
 
Old 05-03-2011, 07:09 PM   #2
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
mh, I think you should read more in the manuals for your system. Every Linux-distribution comes with gcc, most distributions install it by default.

Markus
 
Old 05-04-2011, 08:28 AM   #3
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
The standard compiler for Linux is GCC (it's free and open-source). It should be in pretty much every distro's package repository.

Quote:
Originally Posted by markush View Post
Every Linux-distribution comes with gcc, most distributions install it by default.
I thought that most distros don't have any compilers by default.
 
1 members found this post helpful.
Old 05-04-2011, 08:33 AM   #4
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
Hello

@MTK358: thanks, maybe I was wrong.

I helped archie101 in several threads here at LQ, he's using Arch and should not have any problems finding gcc (I don't indeed remember if it is installed by default ).

Markus
 
Old 05-04-2011, 09:22 AM   #5
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
Quote:
Originally Posted by markush View Post
(I don't indeed remember if it is installed by default
It asks you during installation.

The package for all the development tools is called "base-devel". I'd recommend that the OP installs this instead of just GCC individually.
 
Old 05-05-2011, 04:02 PM   #6
archie101
Member
 
Registered: Apr 2011
Location: u.s
Distribution: arch linux
Posts: 48

Original Poster
Rep: Reputation: 0
I have it installed but i do not know how to open it up and write a program. i looked on archlinux.org and did not find out how to.
 
Old 05-05-2011, 04:06 PM   #7
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
You will have to write a C-program with your favorite text-editor (i.e. vim ) and then compile it
Code:
gcc -o myprogram myprogram.c
where myprogram.c is the name of the sourcefile and the name after the -o option is the name of the compiled outputfile. You may look here: http://pages.cs.wisc.edu/~beechung/ref/gcc-intro.html

Markus
 
Old 05-05-2011, 04:14 PM   #8
honeybadger
Member
 
Registered: Aug 2007
Location: India
Distribution: Slackware (mainly) and then a lot of others...
Posts: 855

Rep: Reputation: Disabled
Write a simple c program. Then compile it using gcc -o <progname.o> <progname.c>.
You can also compile it straightaway with gcc <progname>. In this case the compiled binary name would be a.out.
You can then execute the compiled binary using ./<progname.o> or ./<a.out>.
Hope this helps.
PS: AFAIK _all_ distros come with gcc - unless you specifically did not install it. You can check that with 'whereis gcc'.
 
Old 05-05-2011, 04:16 PM   #9
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4853Reputation: 4853Reputation: 4853Reputation: 4853Reputation: 4853Reputation: 4853Reputation: 4853Reputation: 4853Reputation: 4853Reputation: 4853Reputation: 4853
Quote:
Originally Posted by archie101 View Post
I have it installed but i do not know how to open it up and write a program. i looked on archlinux.org and did not find out how to.
I think that you are confusing a compiler with an IDE (Integrated Development Environment). A short look at the Arch repositories showed up a lot of IDEs for Arch, just try a few if you want.
 
Old 05-05-2011, 04:56 PM   #10
archie101
Member
 
Registered: Apr 2011
Location: u.s
Distribution: arch linux
Posts: 48

Original Poster
Rep: Reputation: 0
i made a file put a simple c program in it saved it and ran gcc -o nameofmyprogram nameofmyprogram.c and it said gcc: error: hello.c: No such file or directory
gcc: fatal error: no input files
compilation terminated
 
Old 05-05-2011, 05:02 PM   #11
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
if your program is hello.c, you should try
Code:
gcc -o hello hello.c
Markus
 
Old 05-05-2011, 05:02 PM   #12
archie101
Member
 
Registered: Apr 2011
Location: u.s
Distribution: arch linux
Posts: 48

Original Poster
Rep: Reputation: 0
and this is my program to anyone who knows c and might find an error with it:

#include <stdio.h>
#include <conio.h>

int main(void) {

printf("hello");

getch();

}
 
Old 05-05-2011, 05:06 PM   #13
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
you should use code-tags for programtext in your posts.

If you delete the line #include <conio.h> and the getch() line it will compile and run.
 
Old 05-05-2011, 05:58 PM   #14
archie101
Member
 
Registered: Apr 2011
Location: u.s
Distribution: arch linux
Posts: 48

Original Poster
Rep: Reputation: 0
now it says hello.c:3:10: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’

and how do i use code-tags?
 
Old 05-05-2011, 06:03 PM   #15
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
You may use the "Go Advanced" button at the bottom of your new post, then you end up in an advanced editor where there is this # character where you can click in order to wrap code-tags around the text.

You may as well use the "quote" button for any post where someone used code-tags and see how it works.

Markus
 
  


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
Can you build a C Compiler without an existing C compiler? (Chicken and the egg?) chutsu Linux - Software 6 12-14-2010 09:57 PM
checking for C compiler default output... configure: error: C compiler cannot create clubbing80s Linux - Software 3 07-05-2010 09:17 PM
checking for C compiler default output... configure: error: C compiler cannot create fiorejm Linux - Software 6 11-12-2009 01:35 PM
My c compiler doesn't work after the cross-compiler installed heracles.cn Linux - Newbie 1 06-05-2007 04:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:44 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