How to compile my first C++ program (geany)?
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.
Related videos on Youtube
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, 2022Comments
-
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 almost 9 yearsYou probably need c++ compiler. Run
sudo apt-get install g++
in terminal ( which is like cmd in windows) -
AlainD almost 9 yearsThanks 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 almost 9 yearsDid 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 typingterminal
in the Ubuntu dash -
AlainD almost 9 yearsI 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 almost 9 yearsJust 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 almost 9 yearsI would have a look at Qt.
-
karel almost 9 yearspossible duplicate of Geany compiler , c programming, Ubuntu 14.04, can't show program output
-
AlainD almost 9 years@the_Seppi: Thanks, Qt looks good. Will give that a go.
-
-
JdeBP almost 9 yearsBecause running into a brick wall is the obvious metaphor? ☺