No output screen when run from file manager

So I have ported a C++ program from windows to linux
and when I run it from terminal all is well. However
when executed from file manager there is no screen output.
The program runs and does what it should, just the problem
of not knowing if there are errors or if its even complete. Is there a way to have it open in terminal automatically?
Thanks.

Well, without knowing what you code is supposed to do, how it talks to the screen etc., it's a bit difficult.

Are you saying that this is written for a text screen session, but you want to fire it from the GUI? You might need to associate the file type with a program in the GUI (I've only done this on Windows) in such a way that it opens a console session to run the command. Of course this might affect all files with that suffix.

You could also write a wrapper that opens the console and forces the command in too.

I hope that this helps,
Robin

Basic C++ code uses stdout, and does not "know" about Windows at all. Windowing requires a fair amount of code - when you run something like it has to call whatever windowing libraries your system has.

Visual Studio handles that in Windows. Since we know zero about your system, we are giving you "zero" kinds of answers. If you want actual help:

  1. what UNIX/Linux system
  2. what gui do you have? KDE, Gnome, etc.
  3. do you use an IDE on the UNIX/Linux side?

If the program is smallish, posting the code will also help.

1 Like

Here are my system details:
EDITION="Cinnamon 64-bit"
DESCRIPTION="Linux Mint 18 Sarah"
DESKTOP=Gnome
TOOLKIT=GTK

Correct!

No, compile from the command line.

Funny thing is just about anything with a file extension I double click in file manager will give me the option to run
in terminal but not this. Mint doesn't show an option to add gnome terminal under "open with other application"

You may want to check the configuration files for links between your program's extension and the terminal to open. Or, for a test, you could give it an extension that opens a window.

Specifically your file associations are broken or do not exist:

Run the file manager (Caja), right-click on the file, select Properties and the Open With tab . Now, click on one of the radio buttons for the listed applications. If none shows, the file you create from compiling has to have recognized extension, as RudiC said. Try .exe as the extension:

from the command line:

mv output_file output_file.exe
# or if it already has an extension:
mv output_file.[whatever is here] output_file.exe

Re-run Caja.

1 Like

I have done this and there is no terminal listed, I have manually added terminal but all that will do is open terminal and not run the program.

I have renamed extension exe,bin,run and they all behave the same as the current no extension.

If I rename to .txt extension, double clicking program
will open dialog with option to run in terminal and it will execute without problem with visible screen output.
But at some point I'm going to forget that .txt file is executable.
Even renaming the extension something like .runme won't work

Try a little lateral thinking.

This is just an idea I found with some code I am writing. OSX 10.7.5 at the time.

Maybe the terminal IS being generated but your executable is so quick that its task is finished before the terminal is seen, hence the terminal is closed down before it is seen.
In my case it is/was a child shell script that called xterm but was so quick that the only way I knew that xterm had been accessed was that 'X' appeared on the MBP dock.

Try putting your executable inside a shell script and run it using xterm or something similar.
Assuming bash, make the last but one line something like:-

read -r -p "Press <CR> to continue:- " -n 1

This will hold the terminal until the ENTER key is pressed.
Once you have tested that it is executing and holding you can remove this line and maybe use sleep <seconds> as a replacement.
The last line, which is optional, should be exit ...

This is just an idea...

Thanks wisecracker, but unfortunately my program is not that quick. It takes a good 30 secs to run and when I associate it with terminal, terminal opens and just sits there till I close it.
I also tried installing another terminal (xterm as you mentioned)
and the results are the same.

Oh.
This is what I suspected earlier. Should have said something. MY bad. Something is wrong in your desktop config file.

Here is a step by step:
Adding new item in the menu - Linux Mint Community

Covering another earlier assumption I had:

-- what does the command "file executable_file_name " think about your executable. There is a header file in C for so-called magic. The file command should recognize your compiled file regardless of name or extension - correctly as an executable image file -- may call it one of several things. If it thinks it is a data file or a binary you have a serious configuration problem. Since bash can run it I am assuming this is not the case.

I don't think there's any problem with my linux. To test I tried
running from another partition with a different mint install and
also from an live debian cd and the results were the same.

Is there a linux equivalent to building a windows console program? or maybe write a script to open in terminal?
I've only been using linux about a month so there's a lot I'm
unfamiliar with. Thanks for the input.

Here is an idea...
Open up a terminal and now that you have xterm installed try from the open terminal this...

xterm -e your_command_with_args

Let us know what the display results are, error or otherwise...

Thanks for the ideas but also a no go.
Xterm opens and just sits there with no output until I close
it.

So what I've done is installed the Allegro library (because I'm familiar with it from win) and added code to make the program
open in a window. All is well now, thanks for all the input everyone.