Eclipse C++ environment quiestion: Conditionally launching an executable - c++

I recently started to putter around with C++ projects in Eclipse. It's definitely a tad trickier than working with Java but I managed to figure out most things.
However, at least one issue is escaping my ability to resolve. I wanted Eclipse to not bother trying to run an executable if a clean build failed.
Currently it pops up an annoying dialog box if the build fails because it appears to be blindly trying to launch. At least my clean build prevents the IDE from launching a stale executable but it would be nice to also get rid of the dialog box.
Any tips out there from Eclipse experts?

Related

Qt Debugger: The GDB process terminated

I am a freshman on Qt Designer.
Recently, I've used Qt creator create my own Qt project, which has been available to serial port. However, when I tried to debug my project, it always showed my with the following message, especially when there were breaks in my projects:
Error: The GDB process teminated.
I am very depressed. I have been getting stuck for several days.
If anyone could give me some instructions, more thanks would be given!
Thank you!
There can be different reasons, with different solutions;
(Below will list those most commonly causing this for me.)
#1 Toolchain
It's maybe related to your toolchain, for example I experienced similar issues, where I was compiling my code with latest MingW, but Qt was built with a little older MingW compiler.
I searched everywhere for the specific MingW, that which Qt was built with, but could not find that.
The only solution for me was to rebuild Qt from scratch (and fix all build errors).
#2 Permission
Another time, I was trying to attach debugger to an App running as root.
After running IDE (and by that the debugger) as root, things started to work.
But sometimes, following below #3 was required, too.
#3 Working Directory
Apps may load dependencies based on current-working-directory, for this case:
If you want to attach-debugger to already running root App:
We need to change the way IDE is launched, for example, open the terminal and cd to where the App requires us to (like directory containing the executable), then launch IDE from terminal (using it's path).
This may only be required when attaching to App(s) running as root, and even there not for all IDEs (but was required for QtCreator v4.x at least).
If you don't attach:
Simply change IDE configurations, I mean, most IDEs allow you to select working-directory (like QtCreator does), first do that and then start debugging.

VSCode c++ configuring for vc toolchain

I'm trying to start a work in vscode , latest C++ plugin version supports ms debugger, so as I'm mostly working under windows it was a signal to try this.
c++ tools plugin from MS and cmake tools were installed.
my test project was however not built . the problem is clear , but I need an advice from experienced vscode users how to solve this right.
cmake doesn't see vc compiler.
(after using QtCreator) I expected that vscode could detect vc installation... however that's not so. ok, I have a two ways:
fill environment variables INCLUDE/LIB/PATH with a headers, libs and binaries
just run vcvarsall.bat x64
Second way is a simple and reliable. so final question is:
how to run .bat at the begining of vscode start?
(I don't mean write another bat/cmd, prepare the environment and run vscode inside the same script after that)
Although the question is fairly old, I'll try to give a useful answer, in case others stumble across, just like I did.
I believe what you are trying to achieve is not possible. Code inherits the environment it was started with. If you did not launch it from a developer command prompt, you will not be able build and debug. (Building might be possible if every task first starts the vcvarsall.bat, but that slows things down by a lot. Debugging I think will still not work.)
If you are willing to, you can check out vector-of-bools CMake Tools extension which does build automation as well as automatic MSVC detection. It builds using CMake (thus you need to write your build scripts using CMake), but it will take care of building just by pressing F7, like what most VS users are familiar with.

"Errors exist in the active configuration, proceed with Launch?" Eclipse Luna 4.4.1, C++, GDB, Linux

Good afternoon,
There is an error that has been occasionally occurring right after my project successfully builds. This error states "Errors exist int he active configuration, proceed with Launch?" This error usually occurs after I get some errors in the build previously, fix/clean them, and rebuild again. It occurs between the build and launching the debugger, because if I am disconnected from the remote system, it pops up before it attempts connecting to GDB.
The project builds without issues, and if I restart eclipse, I am able to build and debug without a problem. The issue is that I end up losing all of my undo states and the general discomfort of having to restart eclipse all the time.
This seems like strictly an eclipse issue,
Things I've tried that have made no difference: Cleaning the project, deleting files, etc. This seems to be a bug in eclispe,
If anyone has any knowledge on how to get rid of this prompts, please advise,
Thank you,

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.