Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » msvc CDT unable to resolve std::function
msvc CDT unable to resolve std::function [message #1716920] Wed, 09 December 2015 03:58 Go to next message
Chef Hoobajoob is currently offline Chef HoobajoobFriend
Messages: 16
Registered: December 2015
Junior Member
Using Eclipse Mars with CDT 8.8 on Windows 7 with Visual Studio 2013 installed.

I found some posts suggesting to add "-std=c++11" as a command line argument to the built-in compiler settings and rebuild the project's index. (Project->Properties->C/C++ General->Preprocessor Include Paths, Macros, etc.->Providers->CDT GCC Built-in Compiler Settings)

Having done that, a simple cpp file with an #include <functional> statement, a main function that includes a use of the function template, and the editor flags the symbol with a red squiggly underline indicating that it can't resolve the symbol.

What could be causing this? How to resolve?

Thanks!

See attached source for reference.
  • Attachment: hello.cpp
    (Size: 0.80KB, Downloaded 185 times)

[Updated on: Wed, 09 December 2015 23:20]

Report message to a moderator

Re: CDT unable to resolve std::function [message #1717024 is a reply to message #1716920] Wed, 09 December 2015 16:26 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
This question is aked many times. Some day the CDT developers will make C++11 the default. But then there will be a slew of questions about C++14.

There are two things that need to be told you want C+11:
1) the compiler
2) the indexer

You've only told the compiler. Now you need to inform the indexer.

    Go to Project ==> C/C++ General ==> Preprocessor Include Paths, Macros, etc.
    Select the Providers tab.
    Make sure that the compiler Builtin Settings has been checked.
    Select it.
    You then should see the discovery command in the pane below.

    Verify the command has -std=c++11 (aka -std=c++0x)
    If it doesn't then


      if a global provider is selected follow the link and fix it there
      otherwise fix it in the edit box.


index.php/fa/24247/0/


On the Entries tab, after expanding the builtin line, you should see the following macro definitions:
https://www.eclipse.org/forums/index.php?t=msg&th=1071991&goto=1714109&#msg_1714109
Note that the indexer has problems with <random> and <memorry>

rerun the indexer.
Simple, huh? Smile
Re: CDT unable to resolve std::function [message #1717030 is a reply to message #1717024] Wed, 09 December 2015 16:47 Go to previous messageGo to next message
Chef Hoobajoob is currently offline Chef HoobajoobFriend
Messages: 16
Registered: December 2015
Junior Member
I had already put these changes into the cdt built-in provider.

You say that, on the Entries tab, I should be able to expand the Built-in Compiler Settings line, but the UI does not allow me to do this. It displays an information icon saying "Setting entries for this provider are supplied by the system and are not editable". So, I can't even tell what it's pulling in.

index.php/fa/24248/0/

[Updated on: Wed, 09 December 2015 16:51]

Report message to a moderator

Re: CDT unable to resolve std::function [message #1717036 is a reply to message #1717030] Wed, 09 December 2015 17:19 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
They aren't editable. That's the key word. There doesn't seem to be a a little triangle next to them for expansion so you haven't enabled them or for some strange reason none were found. Try clicking on the Providers tab and see if the builtin settings has been checked. If it is, there may be something wrong with the discovery command. You may have to enable Discovery in the Discovery options but I didn't do this for a sample project recently and the indexer still worked.

index.php/fa/24251/0/

Edit: changed the wording from "selected" to "checked". Hopefully clearer.

[Updated on: Wed, 09 December 2015 17:25]

Report message to a moderator

Re: CDT unable to resolve std::function [message #1717044 is a reply to message #1717036] Wed, 09 December 2015 17:47 Go to previous messageGo to next message
Chef Hoobajoob is currently offline Chef HoobajoobFriend
Messages: 16
Registered: December 2015
Junior Member
The builtin settings on the Providers tab is checked. The Built-in Compiler Settings provider is set to "Use global provider shared between projects", which is where the c++11 command line option is set.
The closest fit seems to be the "Allocate console in the Console View" checkbox on the Discovery tab in Windows>Preferences->C/C++->Build->Settings.

Apparently, if you tick that checkbox, it's supposed to give you a dump of the settings used in the console view when you run the provider.

This doesn't appear to be helpful, because the provider is identified as GCC, so running it results in an attempt to run g++, which is not on my path. I don't even think it exists on my Windows system, unless the CDT bundles it in.

10:37:28 **** Running scanner discovery: CDT GCC Built-in Compiler Settings ****
g++ -std=c++11 -E -P -v -dD C:/Users/hoobajoob/Documents/Eclipse/workspace-sts-luna/.metadata/.plugins/org.eclipse.cdt.managedbuilder.core/spec.C 
Cannot run program "g++": Launching failed

Error: Program "g++" not found in PATH
PATH=<path-goes-here>

10:37:28 Build Finished (took 27ms)

Re: CDT unable to resolve std::function [message #1717051 is a reply to message #1717044] Wed, 09 December 2015 18:00 Go to previous messageGo to next message
Chef Hoobajoob is currently offline Chef HoobajoobFriend
Messages: 16
Registered: December 2015
Junior Member
Apparently the command line you specify in the global location is used differently than in the project-specific location.

As a global setting, this command line:
${COMMAND}  -std=c++11 ${FLAGS} -E -P -v -dD "${INPUTS}"


...will expand ${COMMAND} to g++. In the project scope, ${COMMAND} gets expanded using the config you have for the project's tool chain, which is, of course, cl.exe, which does not recognize any of the options provided in the default command line for the compiler specs:

10:58:34 **** Running scanner discovery: CDT GCC Built-in Compiler Settings ****
cl /c -std=c++11 {FLAGS} -E -P -v -dD C:/Users/hoobajoob/Documents/Eclipse/workspace-sts-luna/.metadata/.plugins/org.eclipse.cdt.managedbuilder.core/spec.C 
Microsoft (R) C/C++ Optimizing Compiler Version 17.00.60610.1 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

cl : Command line warning D9002 : ignoring unknown option '-std=c++11'
cl : Command line warning D9002 : ignoring unknown option '-v'
cl : Command line warning D9002 : ignoring unknown option '-dD'
{FLAGS}
c1 : fatal error C1083: Cannot open source file: '{FLAGS}': No such file or directory
spec.C

10:58:34 Build Finished (took 64ms)


...so, I really have no clue at this point how to configure this correctly.
Re: CDT unable to resolve std::function [message #1717058 is a reply to message #1717051] Wed, 09 December 2015 18:13 Go to previous messageGo to next message
Chef Hoobajoob is currently offline Chef HoobajoobFriend
Messages: 16
Registered: December 2015
Junior Member
David - are you running your Eclipse on Red Hat?

If so, I doubt you're going to encounter any of these problems.

Do you have a Windows 7 system with Visual Studio 2013 installed?
Re: CDT unable to resolve std::function [message #1717062 is a reply to message #1717058] Wed, 09 December 2015 18:34 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Quote:
Do you have a Windows 7 system with Visual Studio 2013 installed?


No and the latest I have of VS is 2008.
I have no idea what the VS options are to achieve a result similar to the GCC one.
They are surprising close but you are going to have to consult the docs for VS.

This may get you started: https://msdn.microsoft.com/en-us/library/hdkef6tk.aspx
These maybe more:
http://www.drdobbs.com/go-parallel/article/print?articleId=232300575&siteSectionName=
http://codeyarns.com/2015/10/02/how-to-change-compiler-options-used-by-indexer-in-eclipse-cdt/

One way is to copy the information from a VS project. Looks painful.
Re: CDT unable to resolve std::function [message #1717064 is a reply to message #1717058] Wed, 09 December 2015 18:46 Go to previous message
Chef Hoobajoob is currently offline Chef HoobajoobFriend
Messages: 16
Registered: December 2015
Junior Member
OK, so some futzing around with settings for the project appears to have cleared up this problem. I suspect other problems remain.

Here is what I changed:

In Project->properties->C/C++ General->Paths and Symbols->Includes:

For both the "GNU C" and "GNU C++" Languages, I manually added, with highest precedence, the VC/include directory for Visual Studio 2013 (the compiler I want to use).
a) Eclipse, for unknown reasons, has convinced itself that I'm interested in using Visual Studio 2012 instead of 2013. There are some 2012 bits on my system from some time ago when I installed VS express, but I can't tell how it came to this decision.
b) Because Eclipse decided to use VS 2012's include folder, it refuses to let me delete it from the list of include directories.
c) I suspect I'm still going to have a problem, because on the "Symbols" tab, Eclipse shows that it's setting _MSC_VER to 1400, which is incorrect for Visual Studio 2013 (it should be 1800), and the UI prevents you from changing these settings in this context (perhaps it can be done elsewhere?)

In Project->properties->C/C++ General->Indexer:

I checked the "Enable project specific settings" and "Use active build configuration" options.

When I clicked "Apply", I got prompted to rebuild the indexes, which I did, and that eliminated the problem. Symbols are resolving correctly now.
Previous Topic:Double backslash in paths
Next Topic:Best fallback for debugging msvc builds built by cdt
Goto Forum:
  


Current Time: Fri Apr 19 22:03:41 GMT 2024

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

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

Back to the top