Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Eclipse C++ Symbol 'std' could not be resolved(When creating "Empty Project" std is unrecognized, but when creating "Hello World C++ Project" std is recognized)
Eclipse C++ Symbol 'std' could not be resolved [message #1700345] Thu, 02 July 2015 05:38 Go to next message
Aaron Cook is currently offline Aaron CookFriend
Messages: 2
Registered: July 2015
Junior Member
Greetings,

I am very new to C++ coding. I'm simply attempting to write scripts that use commands like cout, but I'm having trouble getting Eclipse to resolve it. I open Eclipse, create a new C++ project, and when I select the project type to be "Hello World C++ Project," I am automatically greeted with a source folder and a file with the Hello World program already scripted, implementing std, cout, and endl. However, when I create a new C++ project and select the project type, "Empty Project," I copy/paste the code from the auto-generated Hello World program, and immediately, std, cout, and endl are underlined in red, and Eclipse tells me they cannot be resolved.

Why is this?

I suppose I could work around it by just making all of my projects "Hello World C++ Projects," but I figure I must be missing something here. What's the point of having a project type--Empty Project--that doesn't recognize basic code like 'std'? And should I infer from the name "Hello World C++ Project" that it's only suited for simple programs that display text strings, and that there's some drawback to using it for anything else?

Sorry if my question seems really ignorant or noobish, like I said I'm completely brand new to C++, and I appreciate your time.
Re: Eclipse C++ Symbol 'std' could not be resolved [message #1700494 is a reply to message #1700345] Fri, 03 July 2015 02:05 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 07/02/2015 08:31 AM, Aaron Cook wrote:
> Greetings,
>
> I am very new to C++ coding. I'm simply attempting to write scripts
> that use commands like cout, but I'm having trouble getting Eclipse to
> resolve it. I open Eclipse, create a new C++ project, and when I select
> the project type to be "Hello World C++ Project," I am automatically
> greeted with a source folder and a file with the Hello World program
> already scripted, implementing std, cout, and endl. However, when I
> create a new C++ project and select the project type, "Empty Project," I
> copy/paste the code from the auto-generated Hello World program, and
> immediately, std, cout, and endl are underlined in red, and Eclipse
> tells me they cannot be resolved.
>
> Why is this?
>
> I suppose I could work around it by just making all of my projects
> "Hello World C++ Projects," but I figure I must be missing something
> here. What's the point of having a project type--Empty Project--that
> doesn't recognize basic code like 'std'? And should I infer from the
> name "Hello World C++ Project" that it's only suited for simple programs
> that display text strings, and that there's some drawback to using it
> for anything else?
>
> Sorry if my question seems really ignorant or noobish, like I said I'm
> completely brand new to C++, and I appreciate your time.

Please read the sticky posts at the top of the forum for better and more
efficient help.
Re: Eclipse C++ Symbol 'std' could not be resolved [message #1700765 is a reply to message #1700494] Tue, 07 July 2015 02:24 Go to previous messageGo to next message
Aaron Cook is currently offline Aaron CookFriend
Messages: 2
Registered: July 2015
Junior Member
By sticky posts do you mean this? ---> http://wiki.eclipse.org/Before_asking_a_question_on_the_forums

This is the Eclipse version I'm running:
Version: Luna Service Release 2 (4.4.2)
Build id: 20150219-0600

I've also attached two screenshots of my code for reference.

For the first one (HelloWorldTest.cpp) I went to File > New > C++ Project, and selected under "Project Type," Executable > Hello World C++ Project, and selected under "Toolchains," MinGW GCC. I clicked finish, entered the code you see in the screenshot, and it runs without errors.

index.php/fa/22404/0/

Here's a text copy of the code (copy/pasted from the .cpp file):

//============================================================================
// Name : HelloWorldTest.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main()
{
cout << "Hello World!" << endl; // prints Hello World!
return 0;
}


The second one (CoutTest.cpp), I went to File > New > C++ Project, selected under "Project Type," Executable > Empty Project, and selected under "Toolchains," MinGW GCC. Again, I clicked finish and entered the exact same code as in the first file. I copy/pasted it directly from HelloWorldTest.cpp.

index.php/fa/22405/0/

Here's a text copy of the code:

//============================================================================
// Name : HelloWorldTest.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main()
{
cout << "Hello World!" << endl; // prints Hello World!
return 0;
}


Does that help?

I've also attached a screenshot of the errors from the "Problems" tab. The first error is pointing to a different project. The bottom 3 errors are the ones I'm concerned about, and I wouldn't expect the other project should have anything to do with it.

index.php/fa/22406/0/
Re: Eclipse C++ Symbol 'std' could not be resolved [message #1747363 is a reply to message #1700765] Sun, 13 November 2016 22:16 Go to previous messageGo to next message
kyle wagner is currently offline kyle wagnerFriend
Messages: 1
Registered: November 2016
Junior Member
Hi,

I had this problem as well. It turns out that while I thought I'd resolved the "iostream" include, I hadn't (this resolved the "std" error and it's also responsible for the cout/endl errors).

You can go to Project > C/C++ Index > Search for Unresolved Includes. If it shows that "iostream" is unresolved (which was my case), you need to go to Project > Properties > C/C++ Build > Settings > Tool Settings > GCC C++ Compiler > Inlcudes and add the proper path to wherever the iostream library is on your machine. Then do Project > C/C++ Index > Rebuild.

I'm on a mac running 10.11 (el capitan), and my path to the iostream library was this:

/usr/include/c++/4.2.1/iostream

I figured this out from a stackoverflow post (but can't post the link since this is my first eclipse posting).

stackoverflow.com: questions/10803685/eclipse-cdt-symbol-cout-could-not-be-resolved/10804034#10804034

Hope that helps!
Re: Eclipse C++ Symbol 'std' could not be resolved [message #1747438 is a reply to message #1747363] Mon, 14 November 2016 17:19 Go to previous message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
You'll likely find that the compiler builtins are being included in the Hello World project but not in the Empty project.
Project --> C/C++ General --> Preprocessor Include Paths, Macros, etc
http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Freference%2Fcdt_u_prop_general_sd_entries.htm
If they haven't been, follow the guide to turn them on.
You could also add them by hand either as User Entries or in the tool settings a suggested by Kyle.
Alternatively, only create Hello World projects and delete the generated code.

FWIW, it works fine in Mars and up. You might want to think about upgrading.
In the future, please use minimum sized images.




Previous Topic:cleaning Project fails
Next Topic:[Mac] Eclipse debugging with GDB
Goto Forum:
  


Current Time: Thu Apr 25 11:45:49 GMT 2024

Powered by FUDForum. Page generated in 0.02884 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top