PDA

View Full Version : Run console application directly from directory using double click



atomic
30th January 2015, 19:35
Hi,

I have a simple console application and when I compile and run in Qt Creator it works fine, when I run it from terminal ( Ubuntu ) it works fine but when I try run it directly from directory using double click it doesn't work - nothing happens.

But GUI application ( using widgets ) I can run directly from directory using double click...

Maybe someone know what I am doing wrong?

ChrisW67
30th January 2015, 21:29
Most likely cannot find the libraries it depends on.

anda_skoa
31st January 2015, 05:23
What does the program do?
I.e. how did you determine that it did not run?

Cheers,
_

atomic
31st January 2015, 16:52
This application doesn't do anything - it is a simple example for console application.



I.e. how did you determine that it did not run?


Because I don't see the console.

I am suprised that the gui application without all dependency works fine...
But ok, I will try to copy to directory all dependency and then see if it works.

wysota
31st January 2015, 16:53
Because I don't see the console.
Why would you? Programs do not open terminals on their own.

atomic
1st February 2015, 16:44
Thanks Wysota,
I just starting with linux system and I thought that console application I can run equivalent how in windows.

Update:
I wrote bash script which can run my console application



#!/bin/bash
gnome-terminal -e "./name_of_my_app"


and in file properties I check - allows the file to be executed.

Now it works fine.
Thanks one more time.

anda_skoa
2nd February 2015, 09:40
This application doesn't do anything - it is a simple example for console application.

If it does nothing, it is difficult to know if it has run at all.
Not that it matters, because it wouldn't have done anything anyway :)

Since your other programs work I would just assume this one does as well and just does what it is supposed to do: nothing



I just starting with linux system and I thought that console application I can run equivalent how in windows.

You can.
If the program does nothing, then it won't do anything on Windows either.



I wrote bash script which can run my console application
and in file properties I check - allows the file to be executed.

Now it works fine.


It is like that it also worked fine before.
But since "working" means not doing anything it is nearly impossible to determine whether running it in a terminal changed anything.

You should really implement some functionality that affects the system in some way, e.g. writing a file, before you determine that it does indeed not run when launched directly.

Cheers,
_

d_stranz
2nd February 2015, 21:36
In my experience, running even a "do-nothing" program on Windows (up to and including Win 7) by double-clicking the file name will at least briefly post an MS-DOS command window. Maybe this is happening too quickly to be noticed or the window is behind others, but I am certain that it is still happening. One way to test would be to simply add a sleep() statement with a few seconds' delay to main().

wysota
2nd February 2015, 22:25
In my experience, running even a "do-nothing" program on Windows (up to and including Win 7) by double-clicking the file name will at least briefly post an MS-DOS command window. Maybe this is happening too quickly to be noticed or the window is behind others, but I am certain that it is still happening. One way to test would be to simply add a sleep() statement with a few seconds' delay to main().

It depends whether the program has the console activated or not.

d_stranz
3rd February 2015, 00:27
It depends whether the program has the console activated or not.

Well, yes. I don't know if I have ever written a non-GUI app that didn't include console activation. I suppose servers / services would not ordinarily activate a console. In Visual Studio at least, it takes a little bit of effort to create a non-console, non-GUI app.