• C

linux programming

how do i create a program in c++ using linux.  do i just use the vi editor?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

>>how do i create a program in c++ using linux.  do i just use the vi editor?

You can use the vi editor, but you still need a compiler to create the executable.

You should have a GNU compiler that you can use.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Most Linux installations have better text editors you can use for developing the souce code.

What version of Linux do you have?

To compile your code, go to the command line, and enter the following:
gcc myfile.c

g++ myfile.c

Make sure you're in the same path that your text file is in before issuing the above command line.
Hamed ZaghaghiProgrammerCommented:

first you can use an editor , for example vi, emacs, mcedit, ...
and then if you write your code in c++, use g++, and if you write your code in c, use gcc.
for example;

g++ myprogram.cpp

that compile and link your code and make an executable file named `a.out',

g++ myprogram.cpp -o myprogram

that compile and link your code and make an executable file named `myprogram'.

some hint:

1- you can use `make' utility to make your executable code:

make myprogram

2-if you want to debug your code you must use `gdb'

3-if you want to debug your code with gdb you must add debugging information inyour executable file like this:

g++ -gstabs+ myprogram.cpp -o myprogramm

4-for better programming and debugging in linux, and if you have an X in your linux, you can choose KDevelope for programming,
or other opensource and free IDEs for c/c++ like `anjuta'.

have a good programming day;

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.