C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 01-13-2008, 10:27 PM   #1
Registered User
 
MarkSquall's Avatar
 
Join Date: Aug 2007
Posts: 23
Post How can I compile C and C++ in Linux operating system? Please help.

Dear Cprogramming.com members and administrators,


Good day to everyone. I just want to ask how would I compile my C, and C++ source code in Linux (typically Ubuntu and Fedora) operating system?

Here's the scenario: Our institution is changing our O.S. from Windows to Linux, and thus, my compiler Turbo C and TCLITE (both run in DOS mode), will never work now for Linux. Some forums says it's already in the system of Linux (they said something like gcc), but our personnel said the Ubuntu/Fedora they'd installed doesn't have the gcc compiler; but forum says this is not true, because gcc is already in every Linux O.S., so I don't want to argue with our personnel.

That is why I am asking for everyone's kindest help if you could assist me how can I get/install/use compilers for C and C++ on Linux. And I hope I could get very basic instruction if you please (from installing, using, compiling, etc. Example: first download this, second do that, third apply this etc.). I am totally not familiar with Linux and I really appreciate everyone's help on this. I have downloaded C/C++ for Linux but they are all just IDEs (environments), no compiler was included.


Thank you again and God bless everyone.


Yours truly,

MarkSquall
MarkSquall is offline   Reply With Quote
Old 01-13-2008, 10:39 PM   #2
Registered User
 
Join Date: Sep 2006
Posts: 837
Every version of Fedora has had gcc available in the package repos. The standard Office/Productivity install of Fedora does not include Software Development packages including gcc, so that may have been what they were talking about. However, it's trivial to install the extra packages. Ubuntu is probably similar.

Edit: During a clean Fedora install, including Software Development packages (including gcc) is done by checking one additional checkbox, as described here:

http://docs.fedoraproject.org/instal...selection.html

There is also a graphical method to install the same set of packages after installation, though I'm not familiar with that since I always do it at install time.

Last edited by robatino; 01-13-2008 at 10:49 PM.
robatino is offline   Reply With Quote
Old 01-13-2008, 10:56 PM   #3
Registered User
 
MarkSquall's Avatar
 
Join Date: Aug 2007
Posts: 23
Talking If it is already there, how would I install it?

Dear robatino,


Thank you for the information you gave, but I tried to compile my sample C file, but it said that gcc is not a valid command (I'm sorry I didn't memorized the exact error message). Where could I find the package repos, is it a folder or an .exe file?Is there a way that I could install it myself? What should I do first, second, third, etc.? Can I install gcc even after Ubuntu/Fedora was installed? And can gcc compile C++ source code too?

Thank you and God bless.



Yours truly,

MarkSquall
MarkSquall is offline   Reply With Quote
Old 01-13-2008, 11:02 PM   #4
Registered User
 
Join Date: Sep 2006
Posts: 837
Installing packages requires root privileges, so if you don't have this you'll have to convince the sysadmins to do this for you. If your institution has a large number of programmers, then they should be including the Software Development packages by default. You could, of course, download some compiler as a tarball into your home directory and just use it yourself, but that's nuts. Try to get gcc installed as a proper RPM package first. Once it is, you will be able to run gcc/g++ by just issuing those commands at the prompt, and have man pages for them also.
robatino is offline   Reply With Quote
Old 01-13-2008, 11:18 PM   #5
Registered User
 
Join Date: Oct 2001
Posts: 2,110
Ubuntu uses the apt-get system. Do something like this:

aptitude search gcc | more
aptitude install package

You might want to find the man pages for the CRT also.

http://ubuntuforums.org/
robwhit is offline   Reply With Quote
Old 01-14-2008, 12:41 AM   #6
Registered User
 
kroiz's Avatar
 
Join Date: Jun 2007
Posts: 116
For ubuntu you need from the command line:

Code:
sudo apt-get install build-essential
this will install other things you must have to build a project.
this does not come preinstalled.

also dont expect your windows program to compile on linux without further development.
kroiz is offline   Reply With Quote
Old 03-10-2008, 11:37 AM   #7
Registered User
 
Join Date: Mar 2008
Posts: 1
I guess I'm not really hijacking this thread because the originial question also asked about compiling C code. I'm new to this board but I did a search on my question and the closest I got was this thread.

So what's a good graphical utility to write C code in on a Linux(Ubuntu) operating system? I use Eclipse for JAVA etc but the plugin for C has terrible performance and I don't know how to configure it as I'm new to C and Linux.

Any good free programs out there? Again I'm new to C and Linux so something with a decent debugger and easy setup would be nice.
juiceybananas is offline   Reply With Quote
Old 03-10-2008, 11:50 AM   #8
Super unModrator
 
Join Date: Dec 2007
Posts: 321
Quote:
Originally Posted by juiceybananas View Post
I guess I'm not really hijacking this thread because the originial question also asked about compiling C code. I'm new to this board but I did a search on my question and the closest I got was this thread.

So what's a good graphical utility to write C code in on a Linux(Ubuntu) operating system? I use Eclipse for JAVA etc but the plugin for C has terrible performance and I don't know how to configure it as I'm new to C and Linux.

Any good free programs out there? Again I'm new to C and Linux so something with a decent debugger and easy setup would be nice.
I have Geany and Anjuta. I think Geany is better.
Code:
sudo apt-get install geany
abh!shek is offline   Reply With Quote
Old 03-10-2008, 12:08 PM   #9
uint64_t...think positive
 
xuftugulus's Avatar
 
Join Date: Feb 2008
Location: Pacem
Posts: 355
To MarkSquall:

It is most certain that the administrators of your institution should install the development packages. If they don't you would have to hack your way towards a manual setup in your account space. I know that transition from Windows to Linux is not so straightforward especially for someone not used to the command line.
My sugestion is to try a small Ubuntu install on a personal computer and practice there. It shouldn't be so hard to find a zero-cost box, and linux will happily run nicely on it.
I recommend XUbuntu for starter practicing, as it has an intuitive Desktop environment, and is quite memory-friendly.

Good luck.
__________________
Code:
...
    goto johny_walker_red_label;
johny_walker_blue_label: exit(-149$);
johny_walker_red_label : exit( -22$);
A typical example of ...cheap programming practices.
xuftugulus is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump


All times are GMT -6. The time now is 01:52 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22