Eclipse C++ on OS X - c++

I'm trying to develop programs using C++ and Eclipse on MacOS X but I can't make it work. Please help me configure Eclipse! I have job interviews and I need to refresh my C++ skills!
I installed Eclipse CDT and GCC compiler for MacOS X and I try to compile a simple HelloWorld program (see code below).
#include <iostream>
using namespace std;
int main() {
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
return 0;
}
I get errors and warnings and I can't seem to resolve them. Any help would be much appreciated.
Errors
Symbol 'cout' could not be resolved (Semantic Error),
Same for 'endl',
Same for 'std'.
Warnings
Error launching external scanner info generator (g++),
Error launching external scanner info generator (gcc),
Program 'g++' is not found in $PATH,
Program 'gcc' is not found in $PATH.

On OSX, the compiler comes as part of XCode. So, even if you don't want to use the XCode IDE, you have to install XCode to get the compiler (and linker (and other tools you need)).

Related

Eclipse g++ not found in path: windows

I am attempting to setup SDL2 for C++ with Eclipse on Windows 7.
In order to do so, I am following the tutorial in this link, which states that I must first install MinGW. So I follow the link provided in order to setup MinGW. I follow all the steps without issue. I then open Eclipse and attempt to build a simple hello world program:
#include <iostream>
using namespace std;
int main() {
cout << "Hello World!" << endl;
return 0;
}
To my surprise, this code doesn't build, with 6 errors.
I then proceed to simplify the program further:
int main()
{
return 0;
}
This also does not compile. There are two errors:
Program "g++" not found in PATH
Program "gcc" not found in PATH
Here is a screenshot.
However, my path does contain "C:\mingw\bin". I have also tried changing this to "C:\mingw". Looking inside "C:\mingw\bin", I find gcc and g++:
In addition, compiling a test program using the command line (g++ Test.cpp -o Test) works just fine, as does "g++ -v".
I have been searching the web for hours, and can't seem to find an answer as to why Eclipse can't seem to compile anything with MinGW. Questions I have looked at on SO (which haven't been able to fix my issue) include:
Eclipse mingw binary not found
Eclipse not finding c std libraries
g++ not found in path
Eclipse C++ : "Program g++ not found in PATH"
Program g++ not found in path
Program g++ not found in path C++ [duplicate]
Eclipse CDT (Juno) in Win7: Cannot find g++ in PATH, iostream unresolved and other fun stuff
Additional info:
Window > Preferences > C/C++ > Build > Settings > "CDT GCC Built-in Complier Settings MinGW [Shared]" : Toolchain MinGW GCC is not detected on this system.
I have also reinstalled Eclipse to no avail.
I realize that this may be a duplicate question of some that I have linked, but the information in previous questions have not been able to fix my problem, and I fear that adding a comment to an old question may not result in an answer.
Please request additional information as needed.
You need to set the environment for the c/c++ builder.
First you need to install the GNU tool-chain, you can choose either MinGW or Cygwin. You can see the steps here. I used MinGW.
Go to Window->Preferences->C/C++->Build->Environment and add a new variable, name it whatever you want for example a named it "MINGW", now paste the binaries directory of MinGW which is by default C:\MinGW\bin, you should have something like this:
Now when you create a new project you just have to select the MinGW tool-chain:
Hope that helps.
It appears as though I have fixed the problem for the moment.
In case others encounter the same issue:
Project > Properties > C/C++ Build > Settings > MinGW C++ Linker > Command changed from "g++" to "C:\mingw\bin\g++".

I use Eclipse Luna and I'm trying out C++, why does it give me errors when I see people doing it fine?

I use Eclipse Luna and I'm trying out C++, why does it give me errors when I see people doing it fine? I have it set to C/C++, I'm using a C++ project and I have this code:
#include <iostream>
int main()
{
std::cout << "Hello World!";
}
That's the standard C++ 'Hello World!' program.
I don't have much experience with C/C++ and I don't know why Eclipse is giving me these errors:
Errors (2 items)
Program "make" not found in PATH
Symbol 'cout' could not be resolved
It seems you will need to install a compiler and GNU Make. There is a Guide on Code Project under "Additional tools required for CDT" that will walk you through the process.

Commands 'cin' and 'cout' not working

I installed MinGW on Windows 8.1 to code in C++ and I am trying to run my codes using Sublime Text 3. So far I am successful, but I am not being able to use cin and cout. I know I can use scanf and printf, instead. But I might need to use cin and cout as well. When I am trying to build a C++ code containing cin or cout, it gives a compile time error. Let's see at a piece of code which generates such an error:
#include "iostream"
#include "cstdio"
using namespace std;
int main()
{
int n;
std::cin >> n;
std::cout << n;
}
The error coming up on my machine is: (Note:I have WinGHCi installed on my machine to use Haskell)
Info: resolving std::cin by linking to __imp___ZSt3cin (auto-import)
Info: resolving std::cout by linking to __imp___ZSt4cout (auto-importc:/program files (x86)/haskell platform/2013.2.0.0/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe: warning: auto-importing has been activated without --enable-auto-import specified on the command line.
This should work unless it involves constant data structures referencing symbols from auto-imported DLLs.)
[Finished in 1.4s]
Please help me to find what is wrong. I deliberately don't want to use IDEs.
Note that a general suggestion is to use <iostream> instead of "iostream". In this regard, using <iostream> produces the following error on compiling the same code (with "iostream" and "cstdio" replaced by <iostream> & <cstdio>):
Info: resolving std::cin by linking to __imp___ZSt3cin (auto-import)
Info: resolving std::cout by linking to __imp___ZSt4cout (auto-importc:/program files (x86)/haskell platform/2013.2.0.0/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe: warning: auto-importing has been activated without --enable-auto-import specified on the command line.
This should work unless it involves constant data structures referencing symbols from auto-imported DLLs.)
[Finished in 1.8s]
These type or errors is often throwned when you are using:
headers with version x
----------------------
lib with version y
So, check this.
update
If you're using compiler with version 4.6.3 but you're using header of 4.6 (for any reason), you got these kind errors.
Useful command:
which g++ #locate where is your compiler (generally /usr/bin/g++)
g++ --version #get compiler's version
find / -name iostream | grep c++ #find where're your includes

I am getting 5 errors in my "hello world" C++ program

My code is...
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!\n";
}
The errors i am getting are...
Description Resource Path Location Type
Symbol 'std' could not be resolved main.cpp /First/src line 3 Semantic Error
Program "g++" not found in PATH First [Discovery Options] page in project properties C/C++ Problem
Program "gcc" not found in PATH First [Discovery Options] page in project properties C/C++ Problem
Symbol 'cout' could not be resolved main.cpp /First/src line 8 Semantic Error
Program "make" not found in PATH First C/C++ Problem
Does anybody know whats wrong? This is my first time trying C++ and i am using eclipse-cpp-kepler-SR1-win32-x86_64
I can't comment yet but based on the error messages it seems that the compiler has not been setup properly or Eclipse cannot find it.
http://www.eclipse.org/forums/index.php/t/238347/
Make sure Eclipse can find your compiler.
You may have to setup some environment variables.
http://www.computerhope.com/issues/ch000549.htm
Also try following the instruction in the error message.
I hope that helps.
install g++ in your system and set env path!
In my case on osx, the errors on the basic hello world project were caused by something silly. everything was installed but i had no clue that the gcc expected me to read and agree to a License. go to terminal and type $ gcc. i was then prompted with the need to deal with the license agreement. once that was done, eclipse build the hello world project without problem. hope this helps others ...

C++ hello world not working?

I am new to C++ and I am self-teaching. I am using code::blocks, and have a question. When I write hello world, nothing happens. This is what is says in the debugger window:
Building to ensure sources are up-to-date
Selecting target:
Debug
ERROR: You need to specify a debugger program in the debuggers's settings.
(For MinGW compilers, it's 'gdb.exe' (without the quotes))
(For MSVC compilers, it's 'cdb.exe' (without the quotes))
and here is the program:
#include <iostream>
using namespace std;
int main()
{
cout << "Helloworld!" << endl;
return 0;
}
also if you need it, here is the build log:
"hello world again - Debug": The compiler's setup (GNU GCC Compiler) is invalid, so Code::Blocks cannot find/run the compiler.
Probably the toolchain path within the compiler options is not setup correctly?!
Goto "Settings->Compiler and debugger...->Global compiler settings->GNU GCC Compiler->Toolchain executables" and fix the compiler's setup.
Skipping...
Nothing to be done (all items are up-to-date).
Try to download the debugger and the compiler again. It worked for me when I had this problem. Try downloading the 'gdb.exe' from the internet.