Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 01-24-2006, 01:16 AM   #1
Registered: Jan 2006
Posts: 44

Rep: Reputation: 15
How to compile and execute c and c++ programs in linux

How to compile and execute c and c++ programs in linux
Old 01-24-2006, 01:44 AM   #2
LQ Addict
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
You compile C programs with gcc:

$ gcc program.c

For C++ programs:

$ g++

The executables are usually named a.out, so you run them with

$ ./a.out

You can change the name of the executable with the -o option:

$ g++ -otest

This will give you an executable named test, which you can run in the same way as above. Read the man pages for gcc and g++ for more options you can use with them.


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
I can not execute compilied programs guitarfella Fedora 2 04-22-2005 11:45 PM
how to compile C++ programs in linux m_suman Programming 9 03-28-2004 12:14 PM
Root can execute programs lawrencegoodman Linux - Newbie 11 01-28-2004 07:42 AM
Programs execute at startup Greg21 Linux - Newbie 5 06-05-2003 03:07 PM
hwo to execute C programs in linux gonus Programming 9 09-30-2002 05:54 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:45 AM.

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