Eclipse with CDT on Mac - c++

I've been trying to get Eclipse with CDT working on my Mac for a while now. Everything I've searched for talks about Windows and I'm officially stuck.
The errors I get are:
Program "g++" not found in PATH
Program "gcc" not found in PATH
and a few more that seem to stem from a problem with my PATH. I checked gcc, g++, make, and gmake in terminal using --version and they're all installed. Eclipse CDT is supposed to detect where to look for PATH variables and I can't figure out where I would change it or how to change it. Any help would be greatly appreciated!
Edit: The original problem was fixed. My PATH variable in eclipse was empty for some reason so I had to add locations like /usr/bin and /usr/local/bin. Now I get the error that "Symbol 'cout' could not be resolved."
Edit 2: I was able to get everything working by uninstalling everything and reinstalling Eclipse Indigo with CDT.

There is no C / C++ compiler installed.
Options are:
Install gcc from here (best): https://github.com/kennethreitz/osx-gcc-installer
Install all of Xcode (1 gig install)
Install command line tools only from Xcode https://developer.apple.com/downloads/index.action
Once installed make sure you can call the compiler from the command line (type gcc) if it does not work the compiler has not been added to the environment path variable.
Some extra help:
How do I install g++ on MacOS X?

Here is a great tutorial that shows all the necessary steps for linux. I think it should be quite similar.
http://mhandroid.wordpress.com/2011/01/23/using-eclipse-for-android-cc-development/
Maybe you'll have to add the path to gcc to your PATH variable if none of this is helping. It should work like this:
Open up .bash_profile in a text editor. (If you're using TextEdit, you can do this at the command line with "open -a /Applications/TextEdit.app ~/.bash_profile".) Add the line:
export PATH="/usr/local/bin:$PATH"
to the file. Save the file and open up a new terminal, then type "echo $PATH" to see if it worked correctly.
EDIT: Someone else had the exact same output as you and managed to fix it by replacing his Eclipse version with an older one. You may try to use Helios instead of Indigo or Juno. This is just a temporary solution until something better comes up (in case it really works). I actually prefer Indigo and Helios over Juno, to be honest. In case you have any worries - Helios is the release from 2010 and still pretty good.

For cout - do you have #include ? Note that cout is a part of std namespace - you need to either qualify it or use "using" directive.

You have to alter ~/.bash_profile, see below for the procedure:
open terminal window
send cmd echo $PATH, then copy the -bash output
send cmd touch ~/.bash_profile
send cmd open -a TextEdit.app ~/.bash_profile
bash_profile will be opened, an empty text file, it means, it the first time it is created.
write in the empty bash_profile: PATH='paste the copied items from echo $PATH cmd a while a back'
save it and reopen the terminal, verify the echo $PATH again.
Restart your eclipse.

my solution is
in preference-> c/c++ -> build->enviroment add PATH= /usr/local/bin
hope it is fine for you.

Related

configure MinGW with Eclipse CDT

I have searched a lot about this and read most of the available answers for similar problem but I still couldn't solve it. Therefore, any help will be helpful.
I am using Eclipse Mars(Latest version after Luna) on Windows 7
MinGW is installed in "C:\Program Files (x86)\CodeBlocks\MinGW\bin".
Environment variable "Path" contains "C:\Program Files (x86)\CodeBlocks\MinGW\bin;..."
Preferences -> C/C++ -> Build -> Settings -> Discovery->CDT GCC Built-in Compiler Settings : command to get compiler specs
${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"
manually doing gcc -E -P -v -dD in cmd from any directory gives
.
.
Target: mingw32
.
.
Errors:
Program g++/gcc not found in PATH
I make a C++ project, add a file with hello world program in it.
I get errors "unresolved inclusion " and 'printf' could not be resolved.
comment if any other details required
It sounds like you're doing everything correctly.
TWO SUGGESTIONS:
Take a look at this link, and see if you missed anything regarding the MinGW/GCC install:
https://www3.ntu.edu.sg/home/ehchua/programming/howto/EclipseCpp_HowTo.html
Otherwise, consider deleting (or simply renaming) your current Eclipse and installing the CDT (Eclipse for C/C++ Developers) version instead:
http://www.eclipse.org/downloads/
For whatever it's worth, here are a couple of screenshots from my property settings (I'm able to create and successfully build a new C project):
I think your problem is simply because of MinGW path include white spaces in it. just reinstalling MinGW on Root directory "c:\MinGW"will solve your problem.
install MinGW with basic setup packages select "mingw-developer-toolkit, mingw32-base, mingw32-gcc-g++, msys-base". complete installation.
restart your pc. then check your eclipse settings.
I hope your problem is already solved.
I also faced such problems,you need to set environment variable, In path add your MinGW location, if you haven't downloaded MinGW go here for downloading MinGW:
http://sourceforge.net/projects/mingw/files/latest/download?source=files
Simple solution is:
For more and detailed information to fix your problem, it worked for me!
Visit here:
http://www.multigesture.net/articles/how-to-install-mingw-msys-and-eclipse-on-windows/

SublimeLinter cppcheck linter executable not found

I have intalled SublimeLinter and sublimelinter-cppcheck packages to my Sublime Text 3.
The problem is that sublime text is saying SublimeLinter: WARNING: cppcheck deactivated, cannot locate 'cppcheck'. I figured out that cppcheck cannot find linter executable, so I decided that I will add path to linter to my system $PATH property. But the thing is that I cannot find linter executable on my system.
At first I thought that it's not installed but that I realised that it has to install with SublimeLinter package. But it did not. I tried to find it using Unix find command the only result is :
/Users/syky/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/cocoapods-core-0.34.2/lib/cocoapods-core/specification/linter
That is not what I am looking for.
I am using Sublime Text 3, Mac OS X Yosemite and ZSH as my shell.
SublimeLinter is looking for the cppcheck executable, which you apparently haven't installed. It is not looking for a file named linter. Please ensure that you have completely read and understood the SublimeLinter-cppcheck documentation before proceeding. The easiest way to install cppcheck is either via Homebrew or MacPorts (my personal favorite). Otherwise, you'll have to download and compile the source, which, if you're programming in C++, I assume you know how to do.
Once you have cppcheck installed, create a symlink to it in /usr/bin so Sublime can find it. Modifying your ZSH PATH won't do anything, unless you always launch Sublime from Terminal, because the PATH for programs launched from the Dock is different.

"g++" not found in PATH [mac/Eclipse/XCODE installed/CDT downloaded]

I get this error when I try to build a c++ project, however I can run cpp apps in Xcode, I've downloaded CDT for Eclipse, so the compiler must be installed.
echo $PATH:
/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
I'm using Mac, I've found posts saying download gcc or Xcode, or solutions for Windows, it's very frustrating that I can't find the answer for such an easy problem, so please… How can I set the PATH variable for my cpp projects in Eclipse?
This question should help. It looks like you need to install XCode command line tools separately to use compilers and build systems outside of XCode (e.g. on the command line or in Eclipse).

Getting mingw-get to install correctly - mingw/msys path missing plus more!

I'm running windows XP.
I have been following this tutorial and so downloading mingw-get-inst here.
I've done this a couple times and the last time I checked boes to install EVERYTHING including, but not limited to, gcc, g++, MSYS and the MinGW Compiling Suite. I told it to make a program menu shortcut, too.
I believe I have correctly added MinGW/bin to the Environment Settings' Path.
So I have the shortcut to the MSYS shell now. It goes to C:\MinGW\msys\1.0\msys.bat, but the whole msys directory does not exist!
There are tons of "packages" have been downloaded as far as I can tell ("mingw-get show" brings up a lot!), but it doesn't seem like any of it installed correctly.
Also, should I be able to use commands like "g++ foo.cpp -o foo.exe" from cmd.exe or only from the MSYS shell? Because I was unable to use cmd.exe.
Please help!
The MSYS and MinGW installation procedure is a nightmare, and has got worse over the years. If you just want the compiler suite (no UNIX tools like sed, grep), then I suggest you go to Twilight Dragon Media and download GCC from there. If you also want all the tools, including the Bash shell, the easiest way I've found to get them is to install Git for Windows (which you may want anyway), which includes them all. And if you want a C++ IDE that works well with GCC, take a look at Code::Blocks.
What is the result of running, at a cmd.exe prompt, the command echo %Path%? It should (given what you wrote about your system) include “C:\MinGW\bin”—does it?
What is the result of running dir C:\MinGW?
Note that mingw-get show shows details of available packages—those mingw-get knows how to download and install. The installer is a bit primitive, but has gotten better over the last year or so.
If you issue the command $ echo $PATH, you'll notice it contains /mingw/bin But the /mingw directory is unavailable. To mount it, edit the MSYS fstab, adding a line like C:\MinGW /mingw For details, see the MingW Getting Started guide, more specifically section "After Installing You Should..."
You only need to add MinGW/bin to the Windows' Environment Settings' Path if you plan to use MingW's executables outside of MSYS.

g++ not working on Windows command prompt. Cygwin installed

I have installed Eclipse and CDT (to use C/C++ in eclipse CDT is needed), as well as installing Cygwin so that I can compile my files.
In environment variables I've set Path to include the following: "C:\cygwin\bin;"
g++, make and GDC are all installed via Cygwin. I made sure of this by searching for them in the bin folder - they're all there.
If I enter "make" into the windows command prompt, this appears:
make: *** No targets specified and no makefile found. Stop.
If I enter "g++" or "gdc" into the windows command prompt, this appears (or similar):
'g++' is not recognized as an internal or external command,
operable program or batch file.
So, in other words make is working but the rest isn't..but they're in the same bin folder! Has got me completely confused.
If I attempt to open Cygwin Bash Shell, g++, make and GDC all work there.
However, I need it to work in the command prompt so that Eclipse is able to compile the programs I write in the IDE.
If you know why this is happening, please let me know.
I haven't used cygwin much, but my understanding is you have to use it from the cygwin bash shell.
if you need g++, make, etc, use mingw, with it, g++ works from the normal windows command line.
Here is what happened to me and how I fixed it.
My C:\cygwin\bin\g++.exe is a shortcut pointing to C:\etc\alternatives\g++.exe, which points back to C:\cygwin\bin\g++-3.exe.
Replacing g++ with g++-3 worked for me.
In C:\cygwin\bin see whether g++.exe is there. If not, the installation wasn't done properly and you may need to install again. That's what was my problem and it's resolved :)
Adding the cygwin paths to the Path variable worked for me (windows 8.1 64 bit):
Go to system properties and select advanced system properties
Go to environment variables and select Path in system variables, click edit
Add the Cygwin paths...
for 32 bit:
C:\Cygwin\bin;C:\Cygwin\usr\bin
for 64 bit:
C:\Cygwin64\bin;C:\Cygwin64\usr\bin
In the CMD window, try typing bash to start a bash shell in that window. If that doesn't work, then the cygwin bin directory is not on your path.
If it did work, enter type g++ and type make to see the paths that are being used for these commands. I'm pretty sure your problem is with your PATH variable.
You could install a Windows version of which to get some help in figuring out exactly which executables are being run.
Perhaps it's picking up 'make' from somewhere completely different, and your addition to %PATH% is not working.
Also verify it by typing echo %path% in the same command prompt window as you're seeing the problem in, just to make sure.