Configuring Eclipse for MinGW - c++

I am using Eclipse Juno with MinGW (latest version) on my Win7-Laptop.
My example code is successfully built within the IDE, but I can neither run nor debug it!
When I choose Run as=>Local C/C++-Application, I get
Launch failed. Binary not found.
However, there IS an exe-file as a result of the build process!
When I call cmd.exe, navigate to the source directory and call this built exe (a.out.exe), it works without problems!
I guess this is due to wrong/missing configuration of eclipse, but I couldn't find useful info on that so far.
This thread mentions environment variables. I added MinGW and Msys to my PATH variable (that's why I can compile) but I can't run my software in eclipse!
So, what can be done to enable debugging?

I have made a little tutorial.
how to set all for Eclipse have a look it's here https://stackoverflow.com/a/12169583/1322642
Hope it can help you a little bit.

Related

Debugging fails with QtCreator on OSX

I have OSX Yosemite 10.10.5, QtCreator 4.1.0, Qt 5.7.0 and Xcode 7.2.1.
If I write any native C++ program in QtCreator (console, gui - anything) I am unable to debug that program from QtCreator. Breakpoints get ignored, the program executes without pause and runs to completion no matter what I try.
I have tried the Xcode's LLDb, system GDB and Homebrew GDB as debuggers. the versions of GDB fail to start. Homebrew GDB has been codesigned.
This all used to (a few year back) just work beautifully and I am at a loss as to what might have changed.
Curiously, if I generate an exception inside the program - like accessing through a null pointer, the debugger shows me where this happens in just the way I would expect so, presumably, the debugger is running but simply treating me with complete disdain.
I know there are many versions of this question but none seem to address the problem adequately or offer workable solutions, or they apply to much older versions of the products.
Any suggestions?
This version of qtCreator (4.1.0) saw the return of the warning about having the build directory at the same level as the project directory. In Windows, this is done automatically. My mac installation does not get it right. (I may have messed a while back - cannot remember).
So - if the build directory is inside the project directory, debugging fails. Move the build directory up to the same level as the project directory and everything seems to work fine.
You can set the default build directory in the preferences/Build & Run dialogue. The path should start with ../
You will need to think about the folder structure before setting up the project unless you want build folders appearing in awkward places. So, a project folder structure like this is OK:
But one like this is not:
If this was already obvious to you, great. I have been messing with this for ages.
Many thanks to those who replied and anyone else who took the time to read the question. What helped e find it was the suggestion by #AlexanderVX that his setup was the same as mine but his worked. The only bit of my setup he could not see in the screenshots was the start of the build path. So that was the clue.

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.

"Launch failed. Binary not found." error on CDT Kepler Eclipse

Running or debugging anything gives me an extremely frustrating "Launch failed. Binary not found" error. I'm using Eclipse with a CDT plugin installed (specifically, I have the MinGW package installed).
I already tried setting both the user and system PATH variables to include my (MinGW directory)/bin
I also tried building the program before running it.
I also made sure that PE Windows Parser under the project's settings was enabled.
I went to Project Properties > Run/Debug Settings > New > C/C++ Application > Environment > Select > and I selected the Path
I also tried setting the C/C++ Application in the Main tab to the executable file that is made from building the program, but no such file is made when I do build my program. I seriously doubt that this is what's causing the problem, though.
I'm running out of options, and the problem still persists. What else needs to be done? What am I doing wrong?
When I was looking through the install instructions for MinGW, the tutorial referenced the mingw base package as the package to install after installing MinGW. But mingw base was not available to me. Instead, I saw mingw32 base. Could it be that Eclipse, a 64 bit program, is trying to run 32 bit code? Is that what's going on? If that's the problem, how do I fix it?
Build
Refresh the project. A new folder named Binaries will appear now in project explorer.
Now Run :)
It took me 3 days to figure out my problem. My Hello World C program would compile in eclipse using the Windows PE Parser, but there was NO EXE FILE!!!! AVAST Antivirus was identifying the exe file as a false positive and removing it....grrrrr. The solution was to add the eclipse workspace folder to the exclusions list. Voila!! Eclipse generated my test.exe file.
save the file first before you build and run... it works with me
Check the compiler you set while you created the project . If that is MINGW or Visual Studio ; check whether they are downloaded or not . If not do so and start a new project by closing the old one . Build the new project by pressing Ctrl + B and a new file 'Binaries' is created in the package explorer . Now you can use the run option to run the project .
First the solution: install "make"
I had the same issue.
I also tried the steps you did with no luck.
After some time i found a the solution!
The problem was that i did not have the application "make".
Apparently its not installed by default on Cygwin and eclipse doesn't give any indication for that...

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

How to correctly configure netbeans 6.7 and c++ on windows?

I have installed and configured NetBeans 6.7 for c++ according to the official manual:
http://www.netbeans.org/community/releases/67/cpp-setup-instructions.html#mingw
Configuration window looks like this:
Unfortunately, at 'compile' command following line is displayed:
/usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf
BUILD SUCCESSFUL (total time: 642ms)
Since i'm on windows and it's no /usr/bin/make, no executable is compiled :(. How to correctly configure NetBeans so it will use make from it's config, not from /usr/bin?
Updated
Problem is only with mingw/msys toolchain. It works OK with cygwin (same /usr/bin/make message is displayed, but executable IS created). So the question can be changed to: Can Netbeans 6.7 work with mingw on Windows, or i'm limited to cygwin?
I had problems getting Netbeans 6.7.1/C++/MinGW working too. I don't know if this will help but I thought I'd describe my experience anyway.
I was having successful builds but Netbeans was unable to launch my executable. I was able to verify that the executable was being built and I could run it from an external command prompt. I was also unable to open the properties on my project.
After a day of searching the net, I found a tidbit of info that lead to the solution.
Basically, it all boiled down to not having the path to my build tools set in the windows environment path. After I set the path environment variable, I cleared all the Netbeans configuration so I could be sure about setting things up from scratch. You can do this by deleting the .netbeans folder in your user directory in c:/Documents and Settings.
That should all be done with Netbeans closed of course. Afterwards, start it up and setup your build configuration before you create any projects or load existing projects. Go to Tools/Options/C++ and point it at the build tools directory you added to your environment path (c:/MinGW/bin and c:/msys/1.0/bin) and the individual tools as required.
I have my msys stuff in the same directory as the MinGW stuff. As an extra precaution, you may want to make sure there are no same named programs in both bin directories that may cause grief.
I seem to have a C++ development environment now that I'm quite pleased with as I can use it in Windows and Linux. Hope something in there helps.
Can you check on the "project options" on your picture and look if the default platform is windows ?
Have installed netbeans on both linux and windows machines and it's strange that it didn't work "straight out of the box" after following the instructions..
You did double check everything right? As it seems that path variable isn't setup correctly in your environment.
The picture also says that the debugger is missing/invalid.. Did you follow these 16 steps (step 14 for installing debugger) or did you use something else?
Last but not least, your "error" message says that the build was successful. Where did you look for the .exe ? It should be under
dist/<Configuration>/<ToolChain>/