Recipe for target failed error in Eclipse using cygwin - c++

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.

Related

Xcode gcc: dependency_info.dat No such file or directory

Hi anyone can help with dependency_info.dat No such file or directory? I'm using Xcode 7 with gcc 4.8
-dependency_info /path/my_project/build/my_project/Debug/my_project.build/Objects-normal/x86_64/my_project_dependency_info.dat
g++-4.8: error:/path/my_project/build/my_project/Debug/my_project.build/Objects-normal/x86_64/my_project_dependency_info.dat: No such file or directory
Command /usr/local/bin/g++-4.8 failed with exit code 1
what does -dependency_info flag do? How can I remove this flag?
The error went away after I deleted the path specified in Build Settings "Path to Linker Dependency Info File" for the project and the targets. So far the app is compiling and running fine without a specified path.
I had a very similar error with Xcode 7.2, OpenCV 3 and El Capitan.
In my case (and probably in yours as well), it's a linker error disguised as something else.
My project builds fine via terminal (because it already has a makefile that uses gcc), but no chance with XCode even after I configure everything in Build Settings pane according to the makefile.
This answer saved me. My OpenCV was installed using macports (it might have been precompiled binaries, or compiled on my machine, can't remember). It turns out that it's compiled with libc++ and not libstdc++.
Changing the C++ Standard Library setting accordingly in Build Settings did the trick for me.
For me it was trying to use a "/" in the app's display name that caused the build error

CodeLite - build settings malfunction

from unknown reason I can't compile a single file/project in C++ in my CodeLite environment.
I'm using latest version of CodeLite, i.e.: 7.0 with pre-installed MinGW libraries. OS/ Windows 7.
Strangely after reinstallation, time and again I get the following error while trying to build/compile C++ project:
C:\Windows\system32\cmd.exe /C " -j 2 -e -f Makefile"
Name'-j' is not recognized as an internal or external command operable program or batch file
When I try to run the program (I was used to click run and get immediate results since it was compiling and running the code at one time) I get absolutely nothing.
Any idea how can I fix this strange issue ? Reinstalling IDE doesn't really help :(
C:\Windows\system32\cmd.exe /C " -j 2 -e -f Makefile".
Do you have MinGW installed? CodeLite 7.0 does not come with MinGW
To fix your problem:
Install MinGW, I recommend using TDM-GCC (make sure you accept the default options by TDM-GCC installer, especially, the install location path)
After the installation is completed, let CodeLite detect your compiler: Settings->Build Settings->Compilers->Add Compiles->Add an existing compiler and point CodeLite to the folder where you installed MinGW
You should now have this compiler configured in CodeLite. right Click on your project and open the settings dialog (keyboard shortcut Alt-F7) : Project settings->Common Settings->General->Compiler and select your compiler from the list
Build your project again, this time it should work properly.
Also, I recommend you to use the latest weekly build (it contains a new "setup wizard" that includes installing a compiler), you can get it from codelite's downloads page
Eran

What do I have to do to set C++ development in eclipse?

I am currently trying to set my eclipse so that I can start c++ development on my Windows computer. However, I am stuck with some errors. But first, here is what I did so far:
Installed the CDT for Eclipse
Installed Cygwin (with the additional packages gcc, gcc and make)
Added all "paths for headers" in Eclipse
The problem is that when I try to run my Hello World program, I get Launch failed. Binary not found.
I already build and rebuild the project but the program is still not running. It must be because of these errors that I have:
/bin/sh: g++: command not found
make: ***[src/HelloWorld.o] Error 127
What can I do to solve these errors?
Try running the Cygwin setup.exe again and select the packages for g++. Search for that and make sure those are installed. It should be under the name gcc-g++. The C++ compiler is installed separately from the C compiler.
Ok, I figured it out by myself. Since this really freaked me out, I want anyone else who has this problem to know how I solved it.
So apparently, since I had g++, gcc and all that installed, it had to be a problem with the path.
So what I did was check my path. If you don't know how to edit it, check this link http://www.computerhope.com/issues/ch000549.htm
So in there, I chose Path under the System variables and clicked on Edit.... What I noticed was that instead of C:\cygwin64 it said C:\cygwin. All I did was append the 64 (since I had installed the 64-bit version of cygwin) and I was done.
I restarted Eclipse, cleaned and built the project and the errors where gone!

How to install C++ plugin to Eclipse?

I have Eclipse Helios and wanted to code C++ using it, but I keep running into the "Launch failed. Binary Not found" error.
I installed the MingW C++ compiler using the "mingw-get-inst-20120426" file and selected the "C compiler, C++ compiler, MSYS Basic System, and MingW Developer Toolkit".
Then I went to Eclipse > project > properties > C/C++ General > Paths and Symbols, then selected the GNU C++ in the Includes tab and added the "C:\MinGW\lib\gcc\mingw32\4.6.2\include\c++" path.
I also went to C/C++ build > Environment and appended the "C:\MinGW\bin;C:\MinGW\msys\1.0\bin" to the PATH.
Then I created a Hello World C++ project, selecting the MingW GCC under Toolchains, and then built the project using the "hammer" icon.
However, once I ran the HelloWorld program it gets the "Launch failed. Binary Not Found" error.
Here is another error:
g++ -IC:\MinGW\lib\gcc\mingw32\4.6.2\include\c++ -O0 -g3 -Wall -c -
fmessage-length=0 -osrc\HelloWorld.o ..\src\HelloWorld.cpp
Internal Builder: Cannot run program "g++": The system cannot find the
file specified.
I also downloaded the CDT (C/C++ Development Tooling) and transferred the "features" and "plugins" folder to the eclipse folder.
Can someone please give me step-by-step on how to resolve this?
Firstly, in the following examples all drive-letters should be replaced with the relevant ones on your system. Not all of these steps are really necessary, but it works (and the more the merrier).
We start with the slightly simpler release config - we want to make it compile.
Go to Project -- Properties
Look if the include directories are correct and in place.
Go to Project -- Properties -- Run/Debug Settings -- NEW -- Main Tab
Set to Release and Browse to the Release folder of the project. If the exe file is not set type in its name.
Switch to Common Tab. Check Allocate Console and Launch in Background. Don't Run yet.
Go to Project -- Properties -- C/C++ Build -- Discovery Options
Tools -- GCC C++ Compiler
"Browse" to the mingw bin folder and select the g++.exe or copy mingw32-g++.exe to g++.exe
Note: The image points to mingw32-g++.exe please use g++.exe
Right click on the project and look -- Build Configurations -- Set Active -- Release is checked.
Right click on the project -- Run As -- Run Configurations.
Under C/C++ Application select, the one which refers to the release version. Then click Run
If this works, I will show you how to set the Debug Properties. (more complicated)
Nowadays (Eclipse Juno and newer), it is much simpler. You just need to:
Install MinGW (and including C++ compiler)
Add the paths "C:\minGW\bin" and "C:\minGW\msys\1.0\bin" (or wherever you installed MinGW to) to your Windows "Path" variable
Install Eclipse. If Eclise already is installed, restart it. it will recognize that MinGW is now available.
Create a New project: "C++ Project"
For every Project type in the following dialog, you should now be able to select the "MinGW GCC" toolchain
Happy coding
See here: http://www.youtube.com/watch?v=QhvXCg2CY4Q
g++ is installed as part of MinGW. If you are getting an error in Eclipse that it cannot find g++ then your path is most likely incorrect. From a command prompt you should be able to run:
g++ --version
and it should display the version of g++ in the MinGW/bin directory.
Eclipse uses this path to locate the include files and the compiler. Once you get the path correct restart Eclipse and the problems listed in your question should be resolved.

Netbeans and MinGW-w64

I'm trying to configure my NetBeans on win7 64bit, to work with the MinGW-w64.
So I put in the %PATH% variable the following paths of the compiler:
C:\mingw-w64-bin_i686\mingw\bin
C:\minGw-MSYS\msys\bin
C:\mingw-w64-bin_i686\libexec\gcc\x86_64-w64-mingw32\4.7.0
Then I opened NetBeans and this was configured:
The configuration in NetBeans
I tried to compile a little test program but I received this error:
g++.exe: fatal error: -fuse-linker-plugin, but liblto_plugin-0.dll not
found compilation terminated. make[2]: *
[dist/Debug/MinGW-Windows/test.exe] Error 1 make1: [.build-conf]
Error 2 make: ** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 1s)
I do have this file in C:\mingw-w64-bin_i686\libexec\gcc\x86_64-w64-mingw32\4.7.0
what am I missing?
Right, after months of putting this off I've finally sat down and done it. I'll probably make a more detailed post on my blog with pretty pictures but here is a trimmed down SO version which will hopefully be enough for you (and everyone else) to get going with.
Prerequisites
Remove MinGW, MSYS and CMake if you have them and can afford to lose them (we will reinstall MinGW (obv.) and MSYS but not CMake as it doesn't appear to be needed.)
Netbeans or other suitable IDE
64bit Windows.
EnvMan (optional but handy for managing Windows Environment
variables.)
Installation
MinGW-W64 C compiler and MSYS
Download and install MinGW-W64
http://mingw-w64.sourceforge.net/ (link is on the left menu with a
hyperlink called 'WIN64 Downloads'.)
There are a lot of versions which can be a bit complicated. We are
going with mingw-w64-bin_i686-mingw_20111220 (although the numbers at
the end may be different) which basically says we want the version
with the windows binaries.
Once the download is complete (about 300mb so 10min or so) extract to
C:\MinGW-W64 or similar. Make sure there aren't any spaces in the
path!
Download MSYS for MinGW-W64
Took a bit of searching
http://sourceforge.net/apps/trac/mingw-w64/wiki/MSYS is the wiki for
it and
http://sourceforge.net/projects/mingw-w64/files/External%20binary%20packages%20%28Win64%20hosted%29/MSYS%20%2832-bit%29/
is where I found the download and the version I went with was
MSYS-20111123
Once the download is complete extract the files to C:\MSys or
similar. Make sure there aren't any spaces in the path!
Setup
Add 'C:\MinGW-W64\bin' to your Windows PATH variable.
Add 'C:\MSys\msys\bin' to your Windows PATH variable.
Start Netbeans and go to Tools -> Options -> C/C++.
Click 'Add' under 'Tool Collection' and select the base directory of
MinGW-W64 (C:\MinGW-W64\bin).
Select 'MinGW' from 'Tool Collection Family' if it isn't
auto-detected and click 'OK'.
Set the 'C Compiler to C:\MinGW-W64\bin\x86_64-w64-mingw32-gcc.exe.
Set the 'C++ Compiler to C:\MinGW-W64\bin\x86_64-w64-mingw32-g++.exe.
Set the 'Make Command' to C:\MSys\msys\bin\make.exe.
And that should be it!
I should note that I am using the system to compile a library file to be use via JNI so have some additional steps for that which I missed out as they weren't needed here. However I made a quick 'Hello World' program and it compiled and ran nicely.
Happy coding!
I have just downloaded the latest automated build, unzipped it, added the main bin directory to path, and run:
x86_64-w64-mingw32-gcc test.cpp -o test.exe
and
x86_64-w64-mingw32-gcc -fuse-linker-plugin test.cpp -o test.exe
and it works. The same for the i686 variant. Your IDE is doing something wrong. Or you shouldn't have messed with the files. Or you shouldn't have removed the prefixes. Seriously.
PS: You only have to add the main "bin" directory to PATH, all the rest is wrong.
With some searching via your favorite Internet search engine, I have come across a better approach to quickly add MinGW-x64 to a Windows 64-bit system. On the Sourceforge site is MSYS2.
While following the installation directions and obtaining the most up to date packages, there may be a time out at the primary mirror site on Sourceforge. If so, follow the mirror site update directions and update the three pacman text files in the respective MSYS2 directory (e.g. /etc/pacman.d). Then proceed to complete the package updates from the MSYS2 installation directions.
Within the MSYS2 packages are things like gcc, llvm, make, dmake, etc. Here is the command used from the MSYS2 command line shell (e.g. bash) to install the GNU make utility:
$ pacman -S msys/make
The executable location it will be placed is: /usr/bin inside the MSYS2 command shell. As far as configuring Netbeans for where make.exe is located, the Windows path is:
MSYS2 installation directory\usr\bin\make.exe
(e.g. C:\msys64\usr\bin\make.exe).
To successfully build C++ with Netbeans, I used the GNU make package (e.g. msys/make). Then in order to use the default make files that Netbeans manages, and to not interfere with other C++ compilers within your Windows installation (e.g. Visual Studio, Intel, CLang from Visual Studio, etc.), run Netbeans from the MinGW-x64 command shell provided by MSYS2. In this way, the environment variables and other things like:
ls rm mkdir
will indicate successful execution and compilation within the Netbeans internal terminal window. I opened the MinGW-w64 Win64 Shell by navigating to the installed shortcut from MSYS2's installation. Then pasted into the MinGW-x64 shell command line, the Target property value from the Netbeans Windows desktop shortcut:
$ "C:\Program Files (x86)\NetBeans 7.4\bin\netbeans.exe"
And then could finally create the respective debug and release object and executable files. I also modified the Netbeans project output to be within the MSYS2 directory structure. Then run the executable within the MSYS2 MinGW-x64 shell. Running from the Netbeans IDE produces this error message:
Unable to start pty process: The application failed with exit code
-1073741515 (0xc0000135).
If the MSYS2 path were in the computer system's PATH environment variable, then perhaps this error would not happen.