Invalid toolchain error with Code::Blocks - c++

"Hello - Debug" uses an invalid compiler. Probably the toolchain path within the compiler options is not setup correctly?! Skipping...
I get the above message when I try to run a simple HelloWorld program as below.
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
return 0;
}
Any idea as to why this is happening and how I could solve it would be useful
FYI : Im using the GNU GCC compiler at the moment, I tried changing this too but there was no use.

Thanks to #Thrustmaster's comment. For anyone stuck with a similar problem in the future just go to Settings->Compiler and Debugger->ToolChain Executables ->Click Auto Detect on the compiler's installation directory . Presto! The IDE auto-detects the path and works!

Well, you could use a terminal (this assumes Linux or Mac OSX, and that GCC is installed):
g++ -o hello hello.cpp
Or, to install GCC on OSX, you have to install Xcode (the registration is free) and then go into Xcode → Preferences → Downloads → Components, and click on the install button next to "Command Line Tools".
To install GCC on Debian based Linux distros, use this: sudo apt-get install g++.

Go to Settings->Compiler and Debugger->ToolChain Executables
In Compilers installation directory, browse and select your MinGW installed Directory
Also for C compiler, browse and go to bin folder which is inside MinGW and select mingw32-gcc.exe
For C++ compiler, select mingw32-g++.exe from there
For Linker for dynamic libs , select mingw32-g++.exe from there
For Linker for static libs, select ar.exe from there
For Debugger, select gdb.exe from there
For Resource Compiler, select windres.exe from there
For Make program mingw32-make.exe from there
thats how it worked for me

This happens because your compiler settings are not configured. This is how i solved my issue
Download MinGW Instaltion Manager
Download mingw32-gcc and mingw32-g++ compilers through MingGW and apply changes.
go to Codeblocks and then settings/toolchain executables
inside program files section configure the C compiler with mingw32-gcc and C++ compiler with mingw32-g++ compiler

Related

MinGW ís not working

I installed the C++ compiler MinGW following this tutorial, but when i used the consol commands:
> gcc --version
g++ (GCC) 4.8.1
......
> g++ --version
g++ (GCC) 4.8.1
......
> gdb --version
GNU gdb (GDB) 7.6.1
i dont receive any information and the console prints 'gcc is not recognizable as internal or external command'
When you execute step 3:
Setup environment variable PATH to include "<MINGW_HOME>/bin" where <MINGW_HOME> is the MinGW installed directory that you have chosen in the previous step.
Be aware that changes made to your path in the control panel don't affect existing consoles.
You need to open up a new console for the path to affect it.
The other possibility is that you've modified the path in a console you were working in but this is the wrong way to do it, since that path will not affect future consoles.
You most likely missed this step:
Setup environment variable PATH to include "<MINGW_HOME>/bin" where <MINGW_HOME> is the MinGW installed directory that you have chosen in the previous step.
What is the output of this command?
echo $PATH
If it does not include "<MINGW_HOME>/bin", you need to make the necessary adjustment.
Besides, that tutorial is somewhat dated. Cygwin Ports does include packages for MinGW, plus precompiled libraries, available from Cygwin's setup.exe. The packages are:
mingw64-i686-gcc
mingw64-i686-gcc-g++
or
mingw64-x86-gcc
mingw64-x86-gcc-g++
depending on your architecture. If you use those packages, the compiler will be installed in /usr/bin (which already is in your PATH), and you can access it (e.g. as i686-w64-mingw32-gcc) right away.

Recipe for target failed error in Eclipse using cygwin

First of all, I know that this question already exists multiple times in Stackoverflow but the answers provided for all of them didn't solve my issue(See section "Solutions worked for others" at the end of this question).
I am using the Eclipse IDE(Juno) with CDT plugin and Cygwin installed in my Windows-7 64-bit platform.
I successfully compiled and run the Hello World 'C' program but the Hello World "C++ program" is having Launch failed. Binary not found error.
I am also having recipe for target project.exe failed error in my auto-generated makefile.
Error line in makefile: #echo 'Building target: $#'
Additionally:
In c/c++ build -> toolchain editor ->
Current toolchain : Cygwin GCC
Current Builder : Gnu Make Builder
Used Tools:
GCC Assembler,
GCC Archiver,
Cygwin C++ Compiler,
Cygwin C Compiler,
Cygwin C Linker,
Cygwin C++ Linker.
When I change Current Builder from "Gnu Make Builder" to "CDT Internal Builder" the recipe for target project.exe failed error disappears but the Launch failed. Binary not found error still exists.
And also I dont have MinGW installed.
Solutions worked for others :
Before running the project directly using the run command, first Build the project and then run.
I build the project every time before I run it.
Eclipse can't find or point to an .exe file but the exe file runs fine when run from windows explorer and the answer to it is add -arch i386 to miscellaneous under linker.
My build runs without error but not creating the exe file. So this doesnt apply to me
Project->Properties->C/C++ Build->Settings->Binary Parsers
set "Cygwin PE Parser" and/or " PE Window Parser" and alike.
Tried all of them with different combinations but did not work
I also did :
adding the cygwin install dir to the path variable
added all the includes folders needed for cygwin for both GNU C and GNU C++ in Paths-and-Symbols -> includes
Saved the project before building and then running
restarted eclipse again
checked if g++ is installed using which g++ in terminal
and so on.
What could be a fix to this problem? Or do I have to install MinGW (I tried already to install MinGW with the installer.exe they provided and it failed on downloading the files several times) and try again.
I couldn't find the solution. Please show me what am I missing here.
Thanks in advance.

Eclipse Linux stock "Hello World"-app doesn't run

I've been developing with C++ in VS2010 but now I am trying to convert
my apps to build and run under Linux. So I've installed Eclipse Indigo
and the CDT package on an Ubuntu linux machine.
When I create the stock "Hello World"-project for C++, I get the
classic "Binary not found" error message. I've combed the internet,
but found no solution.
Through my findings I have gone to:
Project -> Properties -> C/C++ Build -> Tool Chain Editor
and changed the Current Toolchain from Linux GCC to MinGW GCC.
But after rebuilding the project I still have the same error message.
Any suggestions?
The gcc package doesn't necessarily include the C++ compiler. Try:
whereis g++
on the commandline (or g++ -v) to check if it is installed...

New MinGW gcc doesn't do anything

I'm trying to compile a simple helloworld program with MinGW on Windows and nothing happens. No output, no executable, nothing. I've just installed the latest MinGW with their mingw-get-inst-20120421.exe installer. When I use an older version of MinGW that came with Code::Blocks, I am able to compile the program. I'm out of ideas and my googling has been in vain. C:\MinGW\bin is on my path and I'm using MSYS.
Command line parameters in MSYS:
gcc helloworld.c -o helloworld
Execute the console from the Start menu, Start->MingW->MinGW Shell or from filesystem:
C:\MinGW\msys\1.0\msys.bat
Execute gcc in this shell.
Otherwise you will have to add the minGW/bin directory to your PATH environment variable.
Go to the directory where you have you gcc executable. In my case it's:
C:\MingW\bin
From there execute gcc:
gcc myFile.c
If it compiles, than something must screwed up your $PATH

"Launch Failed. Binary Not Found." Snow Leopard and Eclipse C/C++ IDE issue

Not a question, I've just scoured the internet in search of a solution for this problem and thought I'd share it with the good folks of SO. I'll put it in plain terms so that it's accessible to newbs. :) (Apologies if this is the wrong place -- just trying to be helpful.)
This issue occurs with almost any user OS X Snow Leopard who tries to use the Eclipse C/C++ IDE, but is particularly annoying for the people (like me) who were using the Eclipse C/C++ IDE in Leopard, and were unable to work with Eclipse anymore when they upgraded. The issue occurs When users go to build/compile/link their software. They get the following error:
Launch Failed. Binary Not Found.
Further, the "binaries" branch in the project window on the left is simply nonexistent.
THE PROBLEM: is that GCC 4.2 (the GNU Compiler Collection) that comes with Snow Leopard compiles binaries in 64-bit by default. Unfortunately, the linker that Eclipse uses does not understand 64-bit binaries; it reads 32-bit binaries. There may be other issues here, but in short, they culminate in no binary being generated, at least not one that Eclipse can read, which translates into Eclipse not finding the binaries. Hence the error.
One solution is to add an -arch i686 flag when making the file, but manually making the file every time is annoying. Luckily for us, Snow Leopard also comes with GCC 4.0, which compiles in 32 bits by default. So one solution is merely to link this as the default compiler. This is the way I did it.
THE SOLUTION: The GCCs are in /usr/bin, which is normally a hidden folder, so you can't see it in the Finder unless you explicitly tell the system that you want to see hidden folders. Anyway, what you want to do is go to the /usr/bin folder and delete the path that links the GCC command with GCC 4.2 and add a path that links the GCC command with GCC 4.0. In other words, when you or Eclipse try to access GCC, we want the command to go to the compiler that builds in 32 bits by default, so that the linker can read the files; we do not want it to go to the compiler that compiles in 64 bits.
The best way to do this is to go to Applications/Utilities, and select the app called Terminal. A text prompt should come up. It should say something like "(Computer Name):~ (Username)$ " (with a space for you user input at the end). The way to accomplish the tasks above is to enter the following commands, entering each one in sequence VERBATIM, and pressing enter after each individual line.
cd /usr/bin
rm cc gcc c++ g++
ln -s gcc-4.0 cc
ln -s gcc-4.0 gcc
ln -s c++-4.0 c++
ln -s g++-4.0 g++
Like me, you will probably get an error that tells you you don't have permission to access these files. If so, try the following commands instead:
cd /usr/bin
sudo rm cc gcc c++ g++
sudo ln -s gcc-4.0 cc
sudo ln -s gcc-4.0 gcc
sudo ln -s c++-4.0 c++
sudo ln -s g++-4.0 g++
Sudo may prompt you for a password. If you've never used sudo before, try just pressing enter. If that doesn't work, try the password for your main admin account.
OTHER POSSIBLE SOLUTIONS
You may be able to enter build variables into Eclipse. I tried this, but I don't know enough about it. If you want to feel it out, the flag you will probably need is -arch i686. In earnest, GCC-4.0 worked for me all this time, and I don't see any reason to switch now. There may be a way to alter the default for the compiler itself, but once again, I don't know enough about it.
Hope this has been helpful and informative. Good coding!
just for records, after struggling for 30 minutes, i solved this problem on lion (mac 10.7) by selecting Mach-O 64 Parser and Elf Parser under : Project Menu -> Properties->C/c++ Build->Settings->Binary Parsers tab (first tab, or third tab on Eclipse Version: 3.7.2) [ while listening to sweet escape by gwen stefani lol ].
I had been getting the same message of
Launch Failed. Binary Not Found.
because I had not realized I needed to ctrl-click on the project folder and select "Build Project." This does not have to be done in Java projects in Eclipse, so other beginners like myself might have the same problem.
as mentioned, this can be accomplished simply by adding the necessary flag in eclipse.
to do so open the properties window, then go to "c/c++ build" > "settings". In the tree view on the right go to "miscellaneous" of "MacOS X C Linker" and "GCC C compiler" and append in the textbox labelled ~"flags" : "-arch i686"
I'm running Mac OSX 10.6.8, and my Eclipse had the Cross GCC toolchain installed. So, I did this:
Under the Properties for the project, select C/C++ Build -> Tool Chain editor.
Change the Current toolchain from Cross GCC to MacOSX GCC.
I also changed the Current builder to CDT Internal Builder. (I'm not sure if this mattered.)
I left all the stuff under Settings alone.
Rebuild. You should see a binary with the same name as your project in the Debug folder of your project.
Oh, one more thing Don't forget to make a record of your links before you change them! If you don't want to change the system wide settings, add a directory into PATH before /usr/bin (say, $HOME/bin), and make the symlinks there If you want to change back, here's the code I would use:
cd /usr/bin
sudo rm cc gcc c++ g++
sudo ln -s gcc-4.2 cc
sudo ln -s gcc-4.2 gcc
sudo ln -s c++-4.2 c++
sudo ln -s g++-4.2 g++
You'll want to check your /usr/bin and look for a file that's like "gcc-4.x". If it isn't 4.0 or 4.2, substitute the version numbers above for the version number that you have.
EDIT: Oh, I also have trouble running the 64-bit carbon Eclipse if I'm using GCC-4.0. However, the 32-bit Carbon works great.
I got a program called gcc_select that has a prefs file somewhere and will allow you swap back and forth between multiple versions of gcc...
I think I got it from macports, but I'm not sure.
"as mentioned, this can be accomplished simply by adding the necessary flag in eclipse.
to do so open the properties window, then go to "c/c++ build" > "settings". In the tree view on the right go to "miscellaneous" of "MacOS X C Linker" and "GCC C compiler" and append in the textbox labelled ~"flags" : "-arch i686""
Note that, if you go this route, you can easily check your processor's architecture by invoking the command
uname -p
in the Bash terminal (i.e. Terminal.app) and changing "-arch i686" to "-arch -i386".
Instead go to Project -> Properties;
Select C/C++ Build -> Settings;
Under Tool Settings change the C++ compiler and Linker commands from g++ to g++-4.0. If you are still getting any errors change the c compiler also to gcc-4.0. I changed the C compiler settings also to be on the safe side. Everything is working perfectly fine for me.
Hi I installed Eclipse 32 bit and works perfectly so far on mac Mountain lion.
I was getting the Binary not found on compile but now with the 32 bit Eclipse no problem.
Simply remove "Debug" folder from your project and then run "Build project".