P
P
Pavel Efimov2019-03-18 16:43:13
linux
Pavel Efimov, 2019-03-18 16:43:13

How to run compiled program in Linux (Ubuntu) without terminal?

I'm trying to start programming in Linux, and immediately the question is a problem. In Windows, I wrote the code, compiled it, got EXEshnik as the output. Double click on the program, it starts. On Linux, I wrote a simple C program in notepad (for starters), compiled gcc prog.c -o prog, got a file as output. But I can only run it through the terminal with the ./prog command. How can I launch programs by double-clicking the mouse? And if you also give a simple code with a button and event handling for pressing this button, or any other useful information on this topic (for example, cross-platform), I will be sincerely grateful to you. I would like to develop further.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Cheremisin, 2019-03-18
@neon3

In Linux, as in Windows, as in all other operating systems (I know), there are two types of programs: console and GUI.
Console programs require some kind of terminal or console, respectively, although they can be launched by double-clicking, the result of their work will not always be visible if you do not additionally specify in which environment to run them.
About programs with a graphical interface, everything is simple - they immediately try to open a graphical window. But the program itself will be a little more complicated.
So, you have made and compiled a console program. In the same terminal, you can run it.
Or make a "launcher" like
How to make a "launcher" depends on your graphical environment, but usually you can just make a desktop file, almost everyone in Linux understands it.
Just create a text file prog.Desktopwith the following content (Exec - the full path to your program, Icon - the path to the icon, but you can do without it)

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=true
Exec=/path/to/executable
Name=Name of Application
Icon=/path/to/icon

Here is the guide - https://www.maketecheasier.com/create-desktop-file...
Shl. Yes, I forgot to remind you, make an exit in your program waiting for a keystroke, otherwise you can not consider anything!

N
Ninazu, 2019-03-18
@Ninazu

Sometimes it happens that ELF does not pick up files. For them, you need to create a shortcut, a file with the .desktop extension with similar content

[Desktop Entry]
Name=MyApp
Exec=/home/ninazu/Desktop/myapp
Icon=
Terminal=false
Type=Application

V
vanyamba-electronics, 2019-03-18
@vanyamba-electronics

Your program is most likely running, but in a hidden terminal. Therefore, it seems that nothing happens on a double click. But if it hangs, waiting for input from the user, then the process can be seen with the command
. As for window applications, there is Anjuta for GNOME, and Qt for cross-platform. Here is a link to tutorials and examples:
Qt Examples And Tutorials

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question