LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-14-2020, 11:26 AM   #1
vmelkon
Member
 
Registered: Feb 2007
Location: Canada
Posts: 111

Rep: Reputation: 16
How to run a program in Kubuntu


Hello, I am a noob.
I compiled a very simple program, using Eclipse.
In the DEBUG folder, it generates the program file: WinProjectTest005
If I double click on it, nothing happens.

OS: Kubuntu 18.04.3 LTS (aka Ubuntu 18.04.3 LTS)
I guess the file manager is Dolphin.

On Windows, when you double click on a EXE file, it would popup a cmd window. In Kubuntu nothing happens.

Here is the boring program:
================================


#include <iostream>
using namespace std;




int main()
{
int a, b;

cout<<"!!!Hello World!!!"<<endl; // prints !!!Hello World!!!

cout<<"Enter a value:\n";
cin>>a;
cout<<"\nEnter a value:\n";
cin>>b;
a+=b;
cout<<"\nThe total is = "<<a<<endl;

cin>>a;

return 0;
}
 
Old 01-14-2020, 11:39 AM   #2
hazel
Senior Member
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware, OpenBSD
Posts: 3,918
Blog Entries: 11

Rep: Reputation: 2171Reputation: 2171Reputation: 2171Reputation: 2171Reputation: 2171Reputation: 2171Reputation: 2171Reputation: 2171Reputation: 2171Reputation: 2171Reputation: 2171
Your program doesn't include any graphical interface so it needs a terminal to run in, but KDE hasn't been told that. You can launch such a program from a desktop icon if you create a .desktop file for it specifying that it needs a terminal. I believe some desktops also allow the choice "run in terminal" when you right-click on an executable. Otherwise, you will need to open a terminal and run it from there.
 
Old 01-14-2020, 12:11 PM   #3
vmelkon
Member
 
Registered: Feb 2007
Location: Canada
Posts: 111

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by hazel View Post
Your program doesn't include any graphical interface so it needs a terminal to run in, but KDE hasn't been told that. You can launch such a program from a desktop icon if you create a .desktop file for it specifying that it needs a terminal. I believe some desktops also allow the choice "run in terminal" when you right-click on an executable. Otherwise, you will need to open a terminal and run it from there.
So if I write a program with a GUI, I could double click it and it would display itself?
Does anybody have a simple Linux GUI program I could test?
I downloaded Eclipse and QT which came with QT Creator so far.
 
Old 01-14-2020, 12:20 PM   #4
jsbjsb001
Senior Member
 
Registered: Mar 2009
Location: Earth? I would say I hope so but I'm not so sure about that... I could just be a figment of your imagination too.
Distribution: Currently OpenMandriva. Previously openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,414

Rep: Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762
Quote:
Originally Posted by vmelkon View Post
So if I write a program with a GUI, I could double click it and it would display itself?
Does anybody have a simple Linux GUI program I could test?
I downloaded Eclipse and QT which came with QT Creator so far.
Yes for your first question.

But I'm not sure I understand exactly what you mean by your second question though.

Following on from what Hazel was saying above about running a program in a terminal via KDE; if you right click the shortcut for your program and select "Properties", then in the "Application" tab click on "Advanced Options", you should see an option called "Run in terminal" - if you want to do it via the graphical interface rather then manually editing the .desktop file for your program.
 
Old 01-14-2020, 01:35 PM   #5
vmelkon
Member
 
Registered: Feb 2007
Location: Canada
Posts: 111

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by jsbjsb001 View Post
Yes for your first question.

But I'm not sure I understand exactly what you mean by your second question though.

Following on from what Hazel was saying above about running a program in a terminal via KDE; if you right click the shortcut for your program and select "Properties", then in the "Application" tab click on "Advanced Options", you should see an option called "Run in terminal" - if you want to do it via the graphical interface rather then manually editing the .desktop file for your program.
For the second question, I am asking, is there a small program/project that opens a window with maybe a button and a menu? Better yet, is there a site that teaches GUI programming (C++)?

I don't have a shortcut to my program. I have the program file. The EXE or whatever you want to call it. Let's say the name is MyProgram.

I'm not sure what you mean by .desktop file.

I have a Windows background, so things are different. A program file needs to end with a .EXE. If it does not have that, forget it, Windows won't run it. We just write our little project with C++ and compile it with whatever compiler we have, we just double click the icon and Windows runs it.
 
Old 01-14-2020, 01:38 PM   #6
sevendogsbsd
Senior Member
 
Registered: Sep 2017
Posts: 1,207

Rep: Reputation: 463Reputation: 463Reputation: 463Reputation: 463Reputation: 463
So, Linux (and the BSDs) do not care about file extensions at all, they care about file content. To run your original executable, just open a terminal in the directory where the executable resides and run ./nameofyourexecutable. If you get a "permission denied", the executable bit needs to be set on the file by running
Code:
chmod +x <your executable name>
Perhaps someone else can help with the graphical application as I am not a programmer.

Last edited by sevendogsbsd; 01-14-2020 at 01:42 PM.
 
1 members found this post helpful.
Old 01-14-2020, 01:55 PM   #7
hazel
Senior Member
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware, OpenBSD
Posts: 3,918
Blog Entries: 11

Rep: Reputation: 2171Reputation: 2171Reputation: 2171Reputation: 2171Reputation: 2171Reputation: 2171Reputation: 2171Reputation: 2171Reputation: 2171Reputation: 2171Reputation: 2171
You shouldn't need to use chmod. All locally compiled programs should already have the execute bit set. Just open a terminal and run it.

But to create a program with a GUI, you would need to learn how to use a widget library to provide you with things like windows, buttons and menus. For a KDE desktop, this would be qt. As this is Linux, not Windows, all such libraries have detailed online manuals. If you understand basic C, you can learn how to add widgets to your program.

Last edited by hazel; 01-14-2020 at 01:59 PM.
 
1 members found this post helpful.
Old 01-14-2020, 02:02 PM   #8
Geist
Member
 
Registered: Jul 2013
Distribution: Slackware 14 / current
Posts: 267

Rep: Reputation: Disabled
I'd suggest using a different environment for this, especially beginner programming like this, where you only have one file to worry about.

Here, try this:
Create a directory (aka 'folder') for all of your learning projects inside your home directory.
Make a directory for this current project inside there.
Fire up a simple text editor.
Paste, or rewrite the code in there.

Save the document as main.cpp

Open a terminal emulator, like xterm, or press Ctrl+Alt+T to open one with shortcuts.
cd ~/my_programming_projects/my_current_project

g++ main.cpp
./a.out


That should run your command line program just fine, you won't even need the last "cin>>a;"
cd means change directory (that's why it's good to think of folders as directories)
g++ is the command line 'interface' to the gnu C++ compiler, and, without any additional options other than the filename(s), it will compile the sources into an executable called "a.out", which ./a.out runs.

If you get any errors or warnings, then you will also get the line numbers and all that alongside it, so you can change those in your text editor there.


Now, I'm not saying that this is not a pain in the neck, to an extent, but this will work even when huge titanic things like Eclipse fail on you.
(And why many text editors can do this from within them, because it IS annoying to go back and forth)

Because this is an Eclipse configuration problem, you need to tell it to open your program with a terminal emulator, and from what I remember Eclipse is frustrating to work with for these things.
Linux has many other options, including the simple text editors that have your back on it.

In fact, I'd consider Linux (with the tools installed) an IDE in itself. You can even set up 'inotify' events (don't worry about that right now though) to watch a certain directory for changes and then run an operation on it, like, saving a source code file and then compiling that automagically.

So, while I realize I'm not very helpful with your problem specifically, and that is bad form, ultimately you can do a lot better than Eclipse, and I'm not talking just out of my behind either.
I used to use Eclipse and Visual studio and I while it was easy enough to use in both cases for simple stuff ( although at this point it's been probably a decade or longer so I forgot the options for these) when I wanted custom build steps, like back in the days having external compilers to compile 3d shaders, for example I just couldn't take their needless hoops any longer ,that xml like build script stuff from microsoft and blafjlkjdlfsd, no thanks.

Nowadays all I use is vim with some plugins, even for 'big boy' projects like opentoonz and other such calibers.
(P.S.: excuse the usage of big boy, it's just for illustration purposes :P it does't even scratch nightmare projects that have roots in the pre cambrian era and have been maintained since then)

Last edited by Geist; 01-14-2020 at 02:21 PM.
 
Old 01-14-2020, 03:37 PM   #9
vmelkon
Member
 
Registered: Feb 2007
Location: Canada
Posts: 111

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by Geist View Post
I'd suggest using a different environment for this, especially beginner programming like this, where you only have one file to worry about.

Here, try this:
Create a directory (aka 'folder') for all of your learning projects inside your home directory.
Make a directory for this current project inside there.
Fire up a simple text editor.
Paste, or rewrite the code in there.

Save the document as main.cpp

Open a terminal emulator, like xterm, or press Ctrl+Alt+T to open one with shortcuts.
cd ~/my_programming_projects/my_current_project

g++ main.cpp
./a.out


That should run your command line program just fine, you won't even need the last "cin>>a;"
cd means change directory (that's why it's good to think of folders as directories)
g++ is the command line 'interface' to the gnu C++ compiler, and, without any additional options other than the filename(s), it will compile the sources into an executable called "a.out", which ./a.out runs.

If you get any errors or warnings, then you will also get the line numbers and all that alongside it, so you can change those in your text editor there.


Now, I'm not saying that this is not a pain in the neck, to an extent, but this will work even when huge titanic things like Eclipse fail on you.
(And why many text editors can do this from within them, because it IS annoying to go back and forth)

Because this is an Eclipse configuration problem, you need to tell it to open your program with a terminal emulator, and from what I remember Eclipse is frustrating to work with for these things.
Linux has many other options, including the simple text editors that have your back on it.

In fact, I'd consider Linux (with the tools installed) an IDE in itself. You can even set up 'inotify' events (don't worry about that right now though) to watch a certain directory for changes and then run an operation on it, like, saving a source code file and then compiling that automagically.

So, while I realize I'm not very helpful with your problem specifically, and that is bad form, ultimately you can do a lot better than Eclipse, and I'm not talking just out of my behind either.
I used to use Eclipse and Visual studio and I while it was easy enough to use in both cases for simple stuff ( although at this point it's been probably a decade or longer so I forgot the options for these) when I wanted custom build steps, like back in the days having external compilers to compile 3d shaders, for example I just couldn't take their needless hoops any longer ,that xml like build script stuff from microsoft and blafjlkjdlfsd, no thanks.

Nowadays all I use is vim with some plugins, even for 'big boy' projects like opentoonz and other such calibers.
(P.S.: excuse the usage of big boy, it's just for illustration purposes :P it does't even scratch nightmare projects that have roots in the pre cambrian era and have been maintained since then)
Eclipse is actually working fine for that tiny C/C++ program. It can run it and the bottom area of Eclipse acts line the command line.
I just wanted to run the program outside of Eclipse.

Since I come from a Windows background, I have used Borland C++ and Visual C++ for a long time. Debugging is easy in these apps.
So, I prefer to use a IDE.
I don't want to develop in Visual C++ on Windows, and as a last step, just port to Linux and hit compile.

So, from what I understand, I can make a GUI program and just double click and it should work. I am releaved to hear that.

I'm not sure how you guys are working on opentoonz without an IDE.
vim is very primitive but if it satisfies, go for it.

@sevendogsbsd, yes, the execute bit is set.
 
Old 01-14-2020, 03:53 PM   #10
sevendogsbsd
Senior Member
 
Registered: Sep 2017
Posts: 1,207

Rep: Reputation: 463Reputation: 463Reputation: 463Reputation: 463Reputation: 463
Vim is anything but primitive - I don't use it but the folks I know who can positively FLY using vim. Vim hooks into whatever language you want and has autocompletion, etc. Just gotta know how to use it.

And "opentoonz" is what?
 
Old 01-14-2020, 04:14 PM   #11
Geist
Member
 
Registered: Jul 2013
Distribution: Slackware 14 / current
Posts: 267

Rep: Reputation: Disabled
@sevendogsbsd
opentoonz is just a large and somewhat crusty project (an animation package used by companies like Ghibli to make some of their anime movies, it was used for Futurama, etc) but it works fine with just vim.
I used it as an example that vim is usable for anything, including big projects, big boy was a bit flippant, lol, and ultimately confusing I guess. It's just large, not super duper 'stereotypical enterprise' large, but still big.

@vmelkon
I consider vim the most powerful and 'ergonomic' text editor in existence, I cannot think of anything that matches its usability and 'speed' (and I don't mean speed in processor like terms, but the amount of changes you can introduce to a chunk of text in relation to the effort of invoking the commands/steps to do so).

IDE merely means "integrated development environment", it's not at all different to running a compiler, version control system, build system or whatever from within vim.
In "IDE"s it's merely done for you in the way the makers of the IDE find it best, hence all the different ways to configure them to do the same task.
(Granted, that's also the case for vim, but IDEs are just so huge and bumbling...)

In Eclipse if you hit "run" then internally that just invokes all the tools required to start the build chain, populating various windows with information, updating the IDE text editor with new information, and running the program, hopefully.

IDE just means "a buncha components in one window", whereas my approach is "a buncha components in one or more windows", the result is entirely the same.

As for launching the program in Kubuntu itself by double clicking it, well that requires some configuration I can't remember (but it might be in the "confirmations" "general" options)
Alternatively, you can also right click the file, Actions -> Run with Konsole.

Edit:
Not going to make a new post for this, but I should have addressed you both separately, my bad!

Last edited by Geist; 01-14-2020 at 04:24 PM.
 
Old 01-14-2020, 04:18 PM   #12
sevendogsbsd
Senior Member
 
Registered: Sep 2017
Posts: 1,207

Rep: Reputation: 463Reputation: 463Reputation: 463Reputation: 463Reputation: 463
Thanks Geist - I know what an IDE is, was a dev for about 11 years but got out because not my cup of tea. I understand it, just don't like it

I thought "opentoonz" was a disparaging remark about Open source - thank you for clarifying that!
 
Old 01-15-2020, 07:02 AM   #13
hazel
Senior Member
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware, OpenBSD
Posts: 3,918
Blog Entries: 11

Rep: Reputation: 2171Reputation: 2171Reputation: 2171Reputation: 2171Reputation: 2171Reputation: 2171Reputation: 2171Reputation: 2171Reputation: 2171Reputation: 2171Reputation: 2171
If you want to write programs in an editor, try geany. It's a kind of halfway house between an IDE and a simple editor. Like vim, it has syntax checking. It has tabs for individual files if you are using more than one. It autocompletes function names. It lets you fold up blocks of code that you are not interested in so that you can intensively study the bits that are causing trouble. I like vim but I would never use anything but geany for a programming job.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Uninstall kubuntu 8.04 because of upgrade to kubuntu 8.10 7ser23 Linux - Newbie 8 11-03-2008 12:11 AM
Installing kubuntu on ubuntu with kubuntu CD coolblue Ubuntu 6 06-30-2008 11:53 AM
Kubuntu Desktop (kubuntu-artwork-usplash) nixFreak Linux - Distributions 1 03-04-2007 08:09 PM
k-mail from Kubuntu 606 to Kubuntu "edgy" impeteperry Ubuntu 2 11-08-2006 04:27 AM
Installing kubuntu on ubuntu with kubuntu CD coolblue Linux - Newbie 1 07-12-2005 02:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration