error , Symbol 'vector' could not be resolved

后端 未结 12 837
心在旅途
心在旅途 2021-01-04 00:34

I am using eclipse in linux to develop a c++ application and I am getting this editor annotation error \"Symbol \'vector\' could not be resolved\" from the following code

相关标签:
12条回答
  • 2021-01-04 01:05

    Apparently vector belongs to C++ standard template library from MinGW perspective. so in addition to

     #include <vector>
    

    Add

    using namespace std;
    

    after the header file inclusions.

    0 讨论(0)
  • 2021-01-04 01:06

    See Also related question: Eclipse CDT: Symbol 'cout' could not be resolved

    for me the problem was that in #include <vector> somewhere there is #include <bits/c++config> which has a different include path than #include <vector>

    i.e.: /usr/include/c++/4.6/x86_64-linux-gnu

    0 讨论(0)
  • 2021-01-04 01:06

    I know that this problem was already solved, but it still appears as the top result on Google.

    Using Eclipse Neon for Linux I solved it with Quick Fix:

    • right click at "vector" in the editor,
    • then "Quick Fix"
    0 讨论(0)
  • 2021-01-04 01:13

    Created a *.cpp file that includes the *.h where the error is showing. This will force Eclipse to backtrace dependencies for *.h.
    Is working for me...

    0 讨论(0)
  • 2021-01-04 01:16
    #include<vector>
    

    should be included at top.

    0 讨论(0)
  • 2021-01-04 01:17

    Most likely you have some system-specific include directories missing in your settings which makes it impossible for indexer to correctly parse iostream, thus the errors. Selecting Index -> Search For Unresolved Includes in the context menu of the project will give you the list of unresolved includes which you can search in /usr/include and add containing directories to C++ Include Paths and Symbols in Project Properties.

    On my system I had to add /usr/include/c++/4.6/x86_64-linux-gnu for bits/c++config.h to be resolved and a few more directories.

    Don't forget to rebuild the index (Index -> Rebuild) after adding include directories.

    0 讨论(0)
提交回复
热议问题