How do I program in ubuntu?

Discussion in 'Software' started by judoka, Jul 13, 2009.

  1. judoka

    judoka Private E-2

    I'm new to Ubantu and just installed version 9.04, I did some research and downloaded build-essentials gcc file for programming in C++, but was disappointed to find-out that it is not in a form of a simple "windows" format like Visual C++ from Microsoft. I don't have experience in using compilers and such that don't require this kind of environment. Can someone offer me some advice on how I can program in C++ in Ubantu begining from where I enter the code all the way to how and where I can see the output. I'm sorry if the question is a silly one, and I appreciate your help.:-o
     
  2. wiebelhaus

    wiebelhaus Private E-2

    If you are a dev you need C and C++ Compiler for your development work.In ubuntu you can install the build-essential for C and C++ compilers.


    Install C and C++ Compilers in Ubuntu
    Code:
    sudo aptitude install build-essential
    This will install all the required packages for C and C++ compilers

    Testing C and C++ Programs & Compiling Your first C Programs

    Now you need to open first.c file
    Code:
    sudo gedit first.c
    add the following lines save and exit the file:
    http://www.ubuntugeek.com/images/c/1.PNG


    Firstly compile the code using the following command
    Code:
    cc -c first.c
    that would produce an object file you may need to add to the library.
    then create an executable using the following command


    Code:
    cc -o first first.c
    Now run this executable using the following command
    Code:
    ./first
    Output should show as follows



    Compiling your first C++ program


    If you want to run c++ program follow this procedure
    g++ is the compiler that you must use.


    you should use a .cpp file extension rather than a .c one


    You need to create a file


    Code:
    sudo gedit first.cpp
    add the following lines save and exit the file:
    http://www.ubuntugeek.com/images/c/2.PNG


    Run your C++ Program using the following command
    Code:
    g++ first.cpp -o test
    Code:
    ./test
    Output should show as follows


     
  3. Dragoneer

    Dragoneer Private E-2


MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds