noob - I can't run program by clicking icon

using linux mint 11 just started C++ and the book I'm using assumes I'm using windows and not the g++ compiler. anyway it says I should be able to execute my new "Hello World" program by clicking icon - i can run it in bash with ./hello but why can't I or how can I run it automatically so I can see the output.

probably not necessary since it's just a "Hello World" but here is the code --

#include <iostream>
using namespace std;

int main()
{
cout << " Hello, world!" << endl;
return 0;
}
If I'm not mistaken, the default behavior of desktop environments for UNIX is not to create a console for programs, even if they do need one. What's probably happening is that the program did indeed run, but you have no way to know this.
I don't think it's possible to change this. Windows knows that it needs to create a console window because console programs and non-console programs are in distinct categories. AFAIK, this isn't the case in Unices.
im guessing your missing the all important

system("PAUSE");

before your return 0;

but im not sure because i am not a Linux guy(YET!)
I kinda thought it was linux default behavior I just thought that maybe there is a way to write in the program to open terminal or a way to use a custom command under edit properties of the program to launch it in a terminal. I'll try system pause but i just read a whole thread of people bashing the use of system anything because as you get further along it becomes bad practice as its supposed to be unsecure. I don't know that since i'm a noob to programming and C++ in genral but I just read it a few minutes ago. thanx tho i'll try it
any other ideas welcome. especially since i'm pretty sure there is a way to change the default linux behavior about opening that terminal with a custom launch command.
~/.Xresources
xterm*hold=true
The window will not be destroyed immediately (asumming that you have xterm) (I don't remember where did I get it)

There is a sticky in the beginner forum about keeping the console open.
Last edited on
ne55 - I don't think that's the problem. when i run ./hello from terminal it stays open . when i click the icon nothing happens not even the terminal opening and closing real quick. before anyone recommends this it is executalbe in permissions. it doesn't seem to know what application or command to use to open it . thats why i think i need to append properties w/ a custom command to tell it wht to do when clicked/opened from the GUI
I got an answer over on the linux mint forum so if anyone else wants the answer here is the thread link http://forums.linuxmint.com/viewtopic.php?f=90&t=83440&p=483573#p483573
Topic archived. No new replies allowed.