How to compile my first C++ program (geany)?

17,782

AlainD,

Geany actually has the options that you're looking for built in. At the top of the screen towards the middle there is a button that looks like a little gear, as well as a button that looks like a brick wall. These are your options for compile and run. Once you've written your code to your satisfaction, you simply click the compile button, and at the bottom of your screen you'll see the output, and if there are any compile time errors. Once complete (assuming no errors) clicking run will cause Geany to open your system's default terminal and execute the program. The terminal will show exit status code when complete and will remain open until you close it.

As for compilers, most major distributions of linux have a pre-packaged collection of compilers and linkers. For ubuntu I believe you would go to the terminal and type the following:

sudo apt-get update
sudo apt-get install build-essential

These two commands will update the list of packages on your system, and then install the essential libraries, headers, and compilers needed for C, C++, and other common programming languages.

Best of luck in your endeavors.

Share:
17,782

Related videos on Youtube

AlainD
Author by

AlainD

By day: Software Engineer using C/C++, Delphi and C#. By night: Musician; World champion of boardgames including Entropy, Lines of Action, Pacru, and Azacru; Represented South Africa and United Kingdom at international Chess, Xiangqi and Backgammon.

Updated on September 18, 2022

Comments

  • AlainD
    AlainD over 1 year

    I'm an experienced Windows developer (Delphi, C/C++, C#, etc). I've just downloaded uBuntu 14.04 64-bit and then looked for some IDEs and saw geany got good reviews. After downloading it, I'm stumped as to how write and compile a simple "Hello world" application.

    Note: I am very new to Linux! The file system looks rather odd to me after 20 years of living in Windows-world, so any help you can offer or a simple step-by-step guide would be much appreciated!

    Thanks.

    • Sergiy Kolodyazhnyy
      Sergiy Kolodyazhnyy almost 9 years
      You probably need c++ compiler. Run sudo apt-get install g++ in terminal ( which is like cmd in windows)
    • AlainD
      AlainD almost 9 years
      Thanks Serg. Where do I find the command prompt? This is a brand new installation of uBuntu 14.04 LTS. I'm assuming that I'd be installing a C++ compiler called "g++", is that right? Would uBuntu pick that up itself or is it something I need to download?
    • steeldriver
      steeldriver almost 9 years
      Did you use the Ubuntu Software Center to download Geany? you can install the g++ package in exactly the same way. If you want to use @Serg's method then you can open a terminal using the Ctrl+Alt+t key combination, or by typing terminal in the Ubuntu dash
    • AlainD
      AlainD almost 9 years
      I downloaded geany via the uBuntu Software Centre. Thanks for the info on starting terminal, just tried it and got it working. Am about to try installing g++ as per Serge's comment. Thanks!
    • AlainD
      AlainD almost 9 years
      Just compiled my first C++, Hello Linux program! Thanks. Named the file HelloWorld.cpp, compiled and ran! Where to from here? Are there any more fully-featured IDEs to create an application like a simple image editor? Is there anything on uBuntu that can be recommended with functionality something like Visual Studio?
    • s3lph
      s3lph almost 9 years
      I would have a look at Qt.
    • karel
      karel almost 9 years
    • AlainD
      AlainD almost 9 years
      @the_Seppi: Thanks, Qt looks good. Will give that a go.
  • JdeBP
    JdeBP almost 9 years
    Because running into a brick wall is the obvious metaphor? ☺