Name:

This is an attempt to share the daily experience with my new apple imac. In doing so I will be adding some interesting information either I find on the net or create by myself. Obviously I have neither any influence nor control over any of the external links you find on this blog. Happy Reading!

Thursday, December 29, 2005

First C++ program on OSX

Installed Xcode 2 with high hopes. Unfortunately, I was lost on the way to run my first c++ program. But then I gave it a try on the Terminal using vim editor. If you are interested, here are the instructions.

It is boring to edit on vim if you have no syntax highlighting. To make it work you should create a file called .vimrc on root directory of the user.

Open the Terminal and type vim .vimrc (When you first open the Terminal you will be on the root directory of the user)

Press "I" to get to insert mode.

Type syntax on

Then press esc button and type :wq to save and exit from vim editor. Next time when you use vim to write a program syntax highlight should be active.

To create your first C++ program

Open the Terminal and type vim first.cpp

Press "I" to get to Insert Mode and type this small program.

Then press esc and :wq to save and exit from vim editor.

Next step is to compile your program. To do that

Type g++ first.cpp -o first and press Enter

This will create an executable file called "first". If you followed my instructions correctly the Terminal should be ready to execute the next command.

Type ./first and press Enter to execute the file.

You should see "Hello World!"

Hope you enjoyed running your first c++ program on osx.

Novice

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home