I am new to Linux. I am using Ubuntu 11.04 and do not know how to compile and execute C++ program in it. I need to know the commands to Compile and Execute a C++ program in Linux.
|
|
|||||||
|
|
I'm making two assumptions here:
The simplest way to compile a C++ program on Ubuntu, or any other Linux distro for that matter, is to type
The above commands assume you are already in the location of the source files, but both the source file and target output file may also be specified as a directory. For example
will compile a C++ source file located on your desktop and place the executable binary in a |
||||
|
|
|
You need g++,for gcc may can't compile cpp file easily.
|
|||||||||
|
|
First of all: to compile and link c++ programs you will need to install a compiler and different development libraries and other programs. The best way this in ubuntu is by installing the From you question it is unclear whether you want to compile an existing or a new program.
If you want to compile a new program yourself you can get started with using I know I got a lot of downvotes for this statement, but I think that if you really want to develop a program in C++ you should get a book. There are just too many steps involved, and since many goods books exist it would be a waste of time to reproduce all of that here. If I would, I would end up with something similar to this site: http://konst.org.ua/articles/en/linuxcom.gnutools.html (which handles C). Perhaps that can get you started. |
|||||||||||||
|