Qt Application not running - c++

I am trying to run a simple "Hello, world" console application but I am experiencing some errors when compiling that I am not familiar with. I have done a bit of research into similar problems with Qt but I haven't been able to find a solution. The closest solution I have come across was to change my Patch Command setting under:
Preferences -> Environment -> System -> Patch Command
to
usr/bin/xterm -e
However, when I try to do this it goes red indicating that I do not have this file.
Environment Preferences Window
The following image is a screenshot of what is displayed in the terminal window when attempting to compile my project.
Console Application Output
Any help on this problem would be much apprectiated! It is very frustrating having something like this hold me back!

Don't run your project in a terminal unless you actually select a working terminal, and that's all. The patch command is irrelevant in this anyway - it's not the terminal, but the patch command -- used to patch source code. You don't need it unless you explicitly use code patching. Go to Projects (Ctrl-5), click on the active Run configuration for your project, uncheck "Run in terminal", done.

Related

c++ executable runs from command line, but not from eclipse

I'm trying to follow a tutorial using the SDL2 library. I've followed the instructions here verbatim.
The program compiles fine, but when I try to run it within eclipse I get the following error when calling SDL_Init(SDL_INIT_VIDEO):
No available video device
After some research I decided this was because SDL2 had not been correctly linked to any display drivers so wasted several hours installing it from source, and trying various fixes suggested on various forums.
After following another tutorial I found that there was nothing wrong with my SDL2 installation. And in fact when I run the executable created by the eclipse project from the terminal, it runs without any problems.
There are similar questions (for example here), but I can't find one where the error occurs from within eclipse, but not the terminal.
Any pointers would be greatly appreciated. I suspect it may be to do with an environment variable not being set, but not sure which or why. Based on answers on SO I added the DISPLAY environment variable and set it to :0 in the project set-up but with no luck.
Update: I found a way to quickly add all of my bash environment variables to my eclipse project and I still get the No available video device error.
Update 2: Turns out I wasn't adding environment variables in the right place (I was adding them to the C++ build environment, not the Run environment; which is obviously where the problem was giving application was building but not running). Posted answer below.
It turns out it was an environment variable problem. To fix you need to add the environment variable DISPLAY to your project and set it to :0.0.
To do this right-click on your project, then select Run As >> Run Configurations...
Then select your application in the left-hand panel. Select the Environment tab on the right. Click New... and then enter DISPLAY in the Name: field, and :0.0 in the Value: field.
Click Apply and then Run, and it should work. Thanks to #Anon Mail for pointing me in the direction of environment variables.

Eclipse runs old code even after building the new one

I started to study c++ and i choosen Eclipse IDE for it.
I need some basic instructions.
Even after i compile my code with ctrl+b Eclipse shows me the old "Hello World" program in console. If i look up the compiled .exe files in my projects "Release" folder i can ran my new program very well.
For some reason Eclipse does not refresh output console.
Any ideas?
Have you tried checking that there are not still multiple consoles open. On the console tab try clicking the Display Selected Console button, or pushing the red terminate button until it becomes greyed out and then running it again.
I saw at the output console's setting's that it is showing my project's Debug release.
So i searched for the compiled in my Debug folder and i saw it was the old .exe of my project.
After that i did the same thing within the Release folder that was the new code!
So all i did was changed the run configuration to Release, pic below.
And now it is working.
Just clean the project from menu...

Juno CDT plugin failing to run a C++ application

I have a simple mixed C/C++ application (OpenGL example) which I have successfully built using Eclipse CDT in Juno (MinGW toolchain).
I can run this application fine by hand from a Win7 command console, but it seems to rarely work when running from Eclipse's "Run as" menu. Whether it works or not seems down to seemingly unrelated changes in the code, and I get nothing of interest on the Eclipse run console (just a <terminated> status) even when no code near the start of the application has changed.
I'd like to and it sometimes I can work around this for now, but would be good to get this working if anyone has any ideas - it seems an essential stepping stone to get the debug environment working in Eclipse.
EDIT Side thought - eclipse seems awfully thin on debug diagnostics when something like this fails. If there is any way to turn on more debug I'd welcome the knowledge =)
Resolved - the issue is down to the path being given to the application, or more specifically the OS launcher (so it can find the DLLs it needs).
Even through the default "run" config claims to inherit the parent environment, it doesn't seem to get the same environment as the Win7 command console. I had to manually edit the "Run as" config in Eclipse to have a custom PATH environment variable containing the directories I needed (MinGW/bin, and a directory containing some custom DLLs).
Cheers, Iso

Eclipse c++ never run when build has errors

When programming in eclipse (c++), I would like to just hit f5 (run) and have the project I'm working on save, build and (if there are no errors) run. If there are errors I want it to show the problems window and stop.
This all works at the moment except for the part where it shouldn't run when there are errors.
Is there a way to make eclipse never run the project when there are errors? Perhaps with an addon?
EDIT: Forgot to mention the prompt... The prompt does show but I want it to not show at all. If you look at the preference window you'll see that there's no 'never' option, there is one for all the other options but not for the 'launch if project contains errors'.
By default, Eclipse CDT does not run code with build errors, but maybe you have checked the option Always launch without asking checkbox.
You should go to Windows menu->Preferences->Run/Debug->Launching->Continue launch if project contains errors and check Prompt option instead of Always. Using this, Eclipse CDT will prompt you if errors exists during building or launch your binary if it has been compiled without errors.

Eclipse Project Run problem

I tried to create a C++ project in Eclipse Helios, it works fine for some simple "Hello World" projects (a single file etc..). However, now I have a little bigger project with several files, the project can still be built without any problems. Actually, when I get into the release folder, the makefile, object files, the actual binary executable are all there. And I could run the binary through the termainl. If I click the "Run/Debug" in Eclipse for this project, it always says "Launch Failed. Binary not found".
How could run the program in Eclipse? I would like to explore its debug features. In addition, I'm running eclipse in CentOS linux and I believe the basic g++, gdb setting etc.. should be all right, otherwise the daemon hello world won't work.
Warning: I have a very old version of eclipse and the CDT so the current procedure could have changed considerably.
In the C/C++ Project view, expand your project then expand the Binaries node. In there you should have a list of the built executables. Right-click on it and select the item Run As.. > Local C/C++ Application. This should automatically create a new run configuration which you can access from the green arrow icon and the little bug icon in your tool bar. Click on these to run normally or to run in debug mode.
If you want to tweak how programs are launched, goto to the Run configuration menu item of the green arrow icon. Select the configuration that you previously created or make a new one. You can then tweak the various launch settings like the executable to run, the arguments you want to pass, the required environment variables, etc.
Note that there's also a separate Debug configuration that can be accessed from the little bug icon in your toolbar. Within that dialog there's a Debugger tab which contains all the controls necessary to set up your debugger. Just randomly screw around with the controls until you find something that works for you.
I just had the same error, and here is what I did - proper binary parser must be selected so Eclipse can recognize the executable:
Select the project, then right click.
Project->Properties->C/C++ Build->Settings->Binary Parsers, PE Windows Parser
(or you can select Cygwin parser if you use Cygwin compiler, on Linux I use Elf parser).
That worked for me at least for Cross compiler (both on Windows 7 and Ubuntu 12.04)