每次我在Eclipse Oxygen CDT中创建一个新项目时,我总是会受到三个主要错误的困扰:“类型'std :: string'无法解决”(或类似的包含问题),“启动失败。二进制文件找不到,“和”启动失败。程序文件不存在“。
我觉得我已经尝试了一切。我已经研究并遵循了以下问题:Eclipse C++: Symbol 'std' could not be resolved ,The program file specified in the launch configuration does not exist,Launch Failed Binary not found Eclipse for C in Windows ,Eclipse CDT project built but “Launch Failed. Binary Not Found” ,“string could not resolved” error in Eclipse for C++ (Eclipse can't resolve standard library) ,C++ - Unresolved inclusion: iostream ,Eclipse c++ Type could not be resolved error even though build is successful ,和How to include a file from another folder? 。
嗨世界示例:
/*
* Hi_world.cpp
*
* Created on: Feb 22, 2018
* Author: Me
*/
//I tried using the actual file paths but that didn't help either
#include <C:\MinGW\lib\gcc\mingw32\5.3.0\include\c++\iostream>
#include <C:\MinGW\include\string.h>
using namespace std;//"Symbol 'std' could not be resolved"
int main()
{
std::string me = "hi world";//"Type 'std::string' could not be resolved"
std::cout << me << std::endl;//"Symbol 'cout' could not be resolved"
// and "Symbol 'endl' could not be resolved"
}
注意:我试图让它在一天内运行几个小时,但是没有成功,所以我保存并退出了eclipse和我的电脑。第二天,我打开计算机,清理,构建并按原样运行我的程序,并在第一次尝试时运行(虽然红色波浪线没有消失)。
听到这个程序构建日志:
12:37:15 **** Rebuild of configuration Debug for project Hi world ****
Info: Internal Builder is used for build
g++ -O0 -g3 -Wall -c -fmessage-length=0 -o Hi_world.o "..\\Hi_world.cpp"
g++ "-LC:\\MinGW" -o "Hi world.exe" Hi_world.o
12:37:17 Build Finished (took 1s.47ms)
听到另一个仍未运行的示例:
#include <iostream>
#include "stdio.h"
#include "time.h"
#include "string.h"
int main ()
{
time_t timer;
struct tm y2k = {0};
double seconds;
y2k.tm_hour = 0; y2k.tm_min = 0; y2k.tm_sec = 0;
y2k.tm_year = 100; y2k.tm_mon = 0; y2k.tm_mday = 1;
time(&timer); /* get current time; same as: timer = time(NULL) */
seconds = difftime(timer,mktime(&y2k));
printf ("%.f seconds since January 1, 2000 in the current timezone", seconds);
return 0;
}
注意:这包含之前提到的所有包含错误,但在干净和重建之间随机发生这些红色波浪形错误消失了。但是,它仍然无法构建并正确运行,并显示错误消息“启动失败。未找到二进制文件。”
听到这个程序构建日志:
12:40:10 **** Rebuild of configuration Debug for project Time ****
Info: Internal Builder is used for build
g++ "-IC:\\MinGW\\lib\\gcc\\mingw32\\5.3.0\\include\\c++\\debug" -O0 -g3 -Wall -c -fmessage-length=0 -o Time.o "..\\Time.cpp"
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\basic_ios.h:37:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:44,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.h: In member function 'std::__cxx11::string std::__cxx11::numpunct<_CharT>::grouping() const':
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.h:1777:7: error: return type 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}' is incomplete
{ return this->do_grouping(); }
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.h: In member function 'virtual std::__cxx11::string std::__cxx11::numpunct<_CharT>::do_grouping() const':
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.h:1845:7: error: return type 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}' is incomplete
{ return _M_data->_M_grouping; }
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.h:2651:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\basic_ios.h:37,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:44,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.tcc: In member function 'void std::__numpunct_cache<_CharT>::_M_cache(const std::locale&)':
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.tcc:88:26: error: invalid use of incomplete type 'const string {aka const class std::__cxx11::basic_string<char>}'
_M_grouping_size = __g.size();
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iosfwd:39:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\stringfwd.h:71:11: note: declaration of 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
class basic_string;
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.h:2651:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\basic_ios.h:37,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:44,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.tcc:90:7: error: invalid use of incomplete type 'const string {aka const class std::__cxx11::basic_string<char>}'
__g.copy(__grouping, _M_grouping_size);
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iosfwd:39:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\stringfwd.h:71:11: note: declaration of 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
class basic_string;
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.h:2651:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\basic_ios.h:37,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:44,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.tcc: In member function '_InIter std::num_get<_CharT, _InIter>::_M_extract_float(_InIter, _InIter, std::ios_base&, std::ios_base::iostate&, std::__cxx11::string&) const':
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.tcc:211:18: error: invalid use of incomplete type 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
__found_grouping.reserve(32);
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iosfwd:39:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\stringfwd.h:71:11: note: declaration of 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
class basic_string;
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.h:2651:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\basic_ios.h:37,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:44,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.tcc:282:10: error: invalid use of incomplete type 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
__xtrc.clear();
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iosfwd:39:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\stringfwd.h:71:11: note: declaration of 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
class basic_string;
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.h:2651:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\basic_ios.h:37,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:44,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.tcc:296:27: error: invalid use of incomplete type 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
if (__found_grouping.size())
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iosfwd:39:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\stringfwd.h:71:11: note: declaration of 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
class basic_string;
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.h:2651:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\basic_ios.h:37,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:44,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.tcc:319:27: error: invalid use of incomplete type 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
if (__found_grouping.size() && !__found_dec)
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iosfwd:39:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\stringfwd.h:71:11: note: declaration of 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
class basic_string;
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.h:2651:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\basic_ios.h:37,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:44,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.tcc:355:27: error: invalid use of incomplete type 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
if (__found_grouping.size())
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iosfwd:39:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\stringfwd.h:71:11: note: declaration of 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
class basic_string;
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.h:2651:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\basic_ios.h:37,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:44,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.tcc: In member function '_InIter std::num_get<_CharT, _InIter>::_M_extract_int(_InIter, _InIter, std::ios_base&, std::ios_base::iostate&, _ValueT&) const':
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.tcc:468:20: error: invalid use of incomplete type 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
__found_grouping.reserve(32);
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iosfwd:39:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\stringfwd.h:71:11: note: declaration of 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
class basic_string;
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.h:2651:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\basic_ios.h:37,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:44,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.tcc:554:22: error: invalid use of incomplete type 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
if (__found_grouping.size())
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iosfwd:39:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\stringfwd.h:71:11: note: declaration of 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
class basic_string;
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.h:2651:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\basic_ios.h:37,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:44,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.tcc:567:55: error: invalid use of incomplete type 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
if ((!__sep_pos && !__found_zero && !__found_grouping.size())
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iosfwd:39:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\stringfwd.h:71:11: note: declaration of 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
class basic_string;
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.h:2651:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\basic_ios.h:37,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:44,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.tcc: In member function 'virtual _InIter std::num_get<_CharT, _InIter>::do_get(std::num_get<_CharT, _InIter>::iter_type, std::num_get<_CharT, _InIter>::iter_type, std::ios_base&, std::ios_base::iostate&, float&) const':
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.tcc:695:13: error: invalid use of incomplete type 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
__xtrc.reserve(32);
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iosfwd:39:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\stringfwd.h:71:11: note: declaration of 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
class basic_string;
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.h:2651:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\basic_ios.h:37,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:44,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.tcc:697:33: error: invalid use of incomplete type 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iosfwd:39:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\stringfwd.h:71:11: note: declaration of 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
class basic_string;
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.h:2651:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\basic_ios.h:37,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:44,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.tcc: In member function 'virtual _InIter std::num_get<_CharT, _InIter>::do_get(std::num_get<_CharT, _InIter>::iter_type, std::num_get<_CharT, _InIter>::iter_type, std::ios_base&, std::ios_base::iostate&, double&) const':
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.tcc:710:13: error: invalid use of incomplete type 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
__xtrc.reserve(32);
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iosfwd:39:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\stringfwd.h:71:11: note: declaration of 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
class basic_string;
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.h:2651:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\basic_ios.h:37,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:44,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.tcc:712:33: error: invalid use of incomplete type 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iosfwd:39:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\stringfwd.h:71:11: note: declaration of 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
class basic_string;
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.h:2651:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\basic_ios.h:37,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:44,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.tcc: In member function 'virtual _InIter std::num_get<_CharT, _InIter>::do_get(std::num_get<_CharT, _InIter>::iter_type, std::num_get<_CharT, _InIter>::iter_type, std::ios_base&, std::ios_base::iostate&, long double&) const':
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.tcc:742:13: error: invalid use of incomplete type 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
__xtrc.reserve(32);
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iosfwd:39:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\stringfwd.h:71:11: note: declaration of 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
class basic_string;
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.h:2651:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\basic_ios.h:37,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:44,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\locale_facets.tcc:744:33: error: invalid use of incomplete type 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale());
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iosfwd:39:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iostream:39,
from ..\Time.cpp:8:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\stringfwd.h:71:11: note: declaration of 'std::__cxx11::string {aka class std::__cxx11::basic_string<char>}'
class basic_string;
^
12:40:10 Build Finished (took 656ms)
我正在使用Windows 10的本机安装,并且正在使用我的计算机上安装的MinGW。这个问题的奇怪之处在于我将启动一个新项目,弹出包含错误,使其无法构建或运行,从而导致其他两个错误,然后我将与之斗争数天,上面的答案,没有在哪里。然后突然出现,我将点击“构建并运行”,程序将正确构建并正常运行(只要我不更改代码或之后单击“清除”)。如果我尝试创建一个类并在类.cpp文件中包含所有方法声明的类头文件,并在.cpp文件中包含类似错误,如上例所示,那就更糟了。
这可能是由于Eclipse CDT或MinGW的绝缘故障造成的吗?是否有我可以在Eclipse中更改的设置,以指定在哪里查找其库(甚至可以帮助?)?任何帮助都非常感激=)。
谢谢!