简体   繁体   English

以某种方式双击Ubuntu显示C ++应用程序?

[英]Somehow display C++ application using double-click on Ubuntu?

I'm totally new to Ubuntu and C++. 我是Ubuntu和C ++的新手。 Anyway, I have PHP experience. 无论如何,我有PHP的经验。

I just created very simple application... 我刚创建了非常简单的应用程序

#include <iostream>



int main() {

    std::cout << "Hello, world!";


    return false;

}

Then compiled it.... 然后编译它....

g++ hello-world.cpp -o hello-world

But I can't open it with double-click on it, like I did on Windows 7. Only way to get that text printed is to do command... 但是我无法打开它,就像我在Windows 7上那样打开它。打印文本的唯一方法就是执行命令...

./hello-world

Is it possible to open compiled file using simple double-click and then get that text somehow printed? 是否可以使用简单的双击打开编译的文件,然后以某种方式打印该文本?

The program you wrote is a console application. 您编写的程序是一个控制台应用程序。 In most Linux GUIs, by default if you open a console program from the GUI, the console output will not be displayed. 在大多数Linux GUI中,默认情况下,如果从GUI打开控制台程序,则不会显示控制台输出。 You can either configure the GUI to open a terminal, or you can manually open a terminal and run it yourself. 您可以配置GUI以打开终端,也可以手动打开终端并自行运行。

When doing development, I highly recommend manually running the program - with using the GUI's automatic terminal window opening mode, the terminal will close as soon as the program terminates; 在进行开发时,我强烈建议手动运行程序 - 使用GUI的自动终端窗口打开模式,终端将在程序终止后立即关闭; so if the program crashes, the message will be lost. 因此,如果程序崩溃,则消息将丢失。 Manually opening a terminal ensures it sticks around after termination, so you can read the program's last messages before terminating. 手动打开终端确保它在终止后粘在一起,因此您可以在终止之前阅读程序的最后消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM