I know how to make C++ programs that can generate output to the terminal/files, but I have to use the terminal/an IDE to do so. How do i make a program executable, so that I can execute it when I click on it.
3 Answers
if you are using linux with gcc/g++ command line compile tool,
compile the program with:
g++ your_program.cpp -o your_program
you can add execute permission to the file with the command:
sudo chmod a+x your_program
and then double click it, it will execute
if you are using windows, and developing under a IDE (like visual studio)
- find the build executable under the project folder, and it should be able to execute by double clicking.

- 145
- 6
-
@DeadMG I am not familiar with mac(i can not afford one), but since mac is also a unix like system, it should be almost the same under linux. You can use xcode as the IDE or just use gcc as the command line compiler. – mars Oct 10 '13 at 05:05
-
OS X is same as with Linux; just use `clang++` or `g++`. – Oct 10 '13 at 06:27
If you are using an IDE, there should be an option to make an executable. Depending on your OS you will have to use a compiler compile your program. For instance
g++ sampleProgram.cpp -o sampleExecutable
This will make you an executable program called sampleExecutable. g++ is the compiler used in this instance.

- 504
- 5
- 15
Go to the folder where your project is saved, in that folder depending upon your O.S. and I.D.E./compiler it should be there. Mine always shows up under bin in my project folder. Good luck.

- 151
- 1
- 1
- 9
-
@Hail2theVictors Just a thought for you, if your just starting out look up C++ primer, and C++ Sams 7th edition. Finally other might yell at me for this but www.cplusplus.com has a tutorial section and down loadable pdf if money is tight. – Ragecoder Oct 10 '13 at 05:10
-